From 9d59712e4a6aad39e0cd9adae84f59883952044c Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 30 Jul 2023 10:51:10 -0700 Subject: feat(anime): show time until next --- src/due/html/anime.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/due/html') diff --git a/src/due/html/anime.py b/src/due/html/anime.py index 92b4670..888e4f0 100644 --- a/src/due/html/anime.py +++ b/src/due/html/anime.py @@ -35,12 +35,32 @@ def anime_to_html(releasing_outdated_anime): continue episodes = anime["episodes"] + airing_at = media["media"]["nextAiringEpisode"]["timeUntilAiring"] + + if airing_at is not None: + hours = airing_at / 3600 + + if hours >= 24: + available = ( + str(available) + + f'] {available + 1} in ~{int(round(hours // 24, 0))} days' + ) + else: + available = ( + str(available) + + f'] {available + 1} in ~{int(round(hours, 0))} hours' + ) + + available = str(available) + "" + else: + available = str(available) + "]" + total_html = ( "" if episodes is None else f'/{episodes}' ) current_html.append( - f'
  • {title} {progress}{total_html} + [{available}]
  • ' + f'
  • {title} {progress}{total_html} + [{available}
  • ' ) current_html = sorted(current_html, key=seen) -- cgit v1.2.3