diff options
| author | Fuwn <[email protected]> | 2023-12-27 04:50:09 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-27 04:50:09 -0800 |
| commit | 3ab1c81e4f7678bd168ff5fbf9ea5f4f38d0c639 (patch) | |
| tree | 18a616f231bf924f839e71c70244ac26acf11c17 /src/lib/Media | |
| parent | fix(manga): disable higher guessing informed (diff) | |
| download | due.moe-3ab1c81e4f7678bd168ff5fbf9ea5f4f38d0c639.tar.xz due.moe-3ab1c81e4f7678bd168ff5fbf9ea5f4f38d0c639.zip | |
fix(match): swap times if needed
Diffstat (limited to 'src/lib/Media')
| -rw-r--r-- | src/lib/Media/Anime/Airing/Subtitled/match.ts | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/lib/Media/Anime/Airing/Subtitled/match.ts b/src/lib/Media/Anime/Airing/Subtitled/match.ts index 5ffeb064..ee0dcfaa 100644 --- a/src/lib/Media/Anime/Airing/Subtitled/match.ts +++ b/src/lib/Media/Anime/Airing/Subtitled/match.ts @@ -10,13 +10,6 @@ export interface Time { day: string; } -export const airedUnsubtitled = (anime: Media) => - anime.nextAiringEpisode?.airingAt && - anime.nextAiringEpisode?.nativeAiringAt && - new Date(anime.nextAiringEpisode.airingAt * 1000).getTime() > Date.now() && - new Date(anime.nextAiringEpisode.nativeAiringAt * 1000).getTime() - Date.now() > - 6 * 24 * 60 * 60 * 1000; - const secondsUntil = (targetTime: string, targetDay: string) => { const now = new Date(); const [targetHour, targetMinute] = targetTime.split(':').map(Number); @@ -96,10 +89,10 @@ export const injectAiringTime = (anime: Media, subsPlease: SubsPlease | null) => // const nativeUntilAiring = airingAt // ? Math.round((airingAt - Date.now() / 1000) * 100) / 100 // : undefined; - const nativeTime = new Date(airingAt ? airingAt * 1000 : 0); + let nativeTime = new Date(airingAt ? airingAt * 1000 : 0); let untilAiring; let time = new Date(airingAt ? airingAt * 1000 : 0); - let nextEpisode = anime.nextAiringEpisode?.episode || 0; + const nextEpisode = anime.nextAiringEpisode?.episode || 0; if ( !( @@ -133,18 +126,9 @@ export const injectAiringTime = (anime: Media, subsPlease: SubsPlease | null) => } } - if (anime.mediaListEntry?.progress === (anime.nextAiringEpisode?.episode ?? 0) - 1) - if ( - // This was an insane debugging session .... What, like eight hours? ... - airedUnsubtitled({ - nextAiringEpisode: { - ...anime.nextAiringEpisode, - airingAt: time.getTime() / 1000, - nativeAiringAt: nativeTime.getTime() / 1000 - } - } as Media) - ) - nextEpisode -= 1; + if (airingAt && nativeTime > time) { + [nativeTime, time] = [time, nativeTime]; + } return { ...anime, |