diff --git a/src/components/use-card-shared-state.ts b/src/components/use-card-shared-state.ts index 77d45eac4..9a13f5eda 100644 --- a/src/components/use-card-shared-state.ts +++ b/src/components/use-card-shared-state.ts @@ -50,7 +50,11 @@ export function useCardSharedState({ inCinema, rerun, newBadge: !inCinema && !rerun ? deriveBadge(meta) : null, - hasDub: settings.showDubBadge && isAnime && dubReady && animeHasDub(meta.id), + hasDub: + settings.showDubBadge && + isAnime && + dubReady && + animeHasDub(meta.id.startsWith("kitsu:") ? meta.malId : meta.id), watched, inWatchlist, inLocalLibrary, diff --git a/src/lib/providers/anime-dub-sub.ts b/src/lib/providers/anime-dub-sub.ts index eb084be73..56cdd962b 100644 --- a/src/lib/providers/anime-dub-sub.ts +++ b/src/lib/providers/anime-dub-sub.ts @@ -1,7 +1,7 @@ import { safeFetch } from "@/lib/safe-fetch"; const FEED_URL = - "https://raw.githubusercontent.com/RockinChaos/AniSchedule/master/raw/dub-schedule.json"; + "https://raw.githubusercontent.com/RockinChaos/AniSchedule/master/raw/v2/dub-schedule.json"; let byMal: Set | null = null; let byAnilist: Set | null = null; @@ -9,23 +9,14 @@ let inflight: Promise | null = null; const subs = new Set<() => void>(); export type DubFeedEntry = { - title?: string | null; - romaji?: string | null; - english?: string | null; - episodeDate?: string | null; - episodeNumber?: number | null; - media?: { - media?: { - id?: number | null; - idMal?: number | null; - type?: string | null; - format?: string | null; - isAdult?: boolean | null; - title?: { romaji?: string | null; english?: string | null } | null; - coverImage?: { extraLarge?: string | null; medium?: string | null } | null; - bannerImage?: string | null; - } | null; - } | null; + id?: number | null; + idMal?: number | null; + format?: string | null; + isAdult?: boolean | null; + title?: { romaji?: string | null; english?: string | null; native?: string | null } | string | null; + coverImage?: { extraLarge?: string | null; medium?: string | null; color?: string | null } | null; + bannerImage?: string | null; + airingSchedule?: { nodes?: Array<{ episode?: number | null; airingAt?: number | string | null }> | null } | null; }; let feedCache: { entries: DubFeedEntry[]; at: number } | null = null; @@ -55,8 +46,8 @@ function load(): Promise { const mal = new Set(); const ani = new Set(); for (const e of arr) { - const m = e?.media?.media?.idMal; - const a = e?.media?.media?.id; + const m = e?.idMal; + const a = e?.id; if (typeof m === "number") mal.add(m); if (typeof a === "number") ani.add(a); } @@ -87,8 +78,10 @@ export function subscribeDubSet(fn: () => void): () => void { }; } -export function animeHasDub(metaId: string): boolean { +export function animeHasDub(metaId: string | number | undefined): boolean { if (!byMal) return false; + if (typeof metaId === "number") return Number.isFinite(metaId) && byMal.has(metaId); + if (metaId == null) return false; if (metaId.startsWith("mal:")) { const m = Number(metaId.slice(4)); if (Number.isFinite(m) && byMal.has(m)) return true;