diff options
| author | Fuwn <[email protected]> | 2023-07-30 10:51:10 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-07-30 10:51:10 -0700 |
| commit | 9d59712e4a6aad39e0cd9adae84f59883952044c (patch) | |
| tree | 2063b546a6209906e688409f769ffdaeedcc1723 /src/due | |
| parent | feat(manga): disable outbound links by default (diff) | |
| download | old.due.moe-0.1.7.tar.xz old.due.moe-0.1.7.zip | |
feat(anime): show time until nextv0.1.7
Diffstat (limited to 'src/due')
| -rw-r--r-- | src/due/anilist/collection.py | 2 | ||||
| -rw-r--r-- | src/due/html/anime.py | 22 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/due/anilist/collection.py b/src/due/anilist/collection.py index aca051a..6c66314 100644 --- a/src/due/anilist/collection.py +++ b/src/due/anilist/collection.py @@ -41,7 +41,7 @@ def media_list_collection_query(user_id: int, type) -> str: type episodes title {{ romaji english native }} - nextAiringEpisode {{ episode }} + nextAiringEpisode {{ episode timeUntilAiring }} mediaListEntry {{ progress }} startDate {{ year }} }} 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'] <span style="opacity: 50%">{available + 1} in ~{int(round(hours // 24, 0))} days' + ) + else: + available = ( + str(available) + + f'] <span style="opacity: 50%">{available + 1} in ~{int(round(hours, 0))} hours' + ) + + available = str(available) + "</span>" + else: + available = str(available) + "]" + total_html = ( "" if episodes is None else f'<span style="opacity: 50%">/{episodes}</span>' ) current_html.append( - f'<li><a href="https://anilist.co/anime/{id}" target="_blank">{title}</a> {progress}{total_html} <a href="/anilist/increment?id={id}&progress={progress + 1}">+</a> [{available}]</li>' + f'<li><a href="https://anilist.co/anime/{id}" target="_blank">{title}</a> {progress}{total_html} <a href="/anilist/increment?id={id}&progress={progress + 1}">+</a> [{available}</li>' ) current_html = sorted(current_html, key=seen) |