From 4b56194ee6807acb56abf0949394efadabf830d4 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 5 Jun 2026 11:10:22 +0000 Subject: feat(airing): replace SubsPlease with AnimeSchedule (sub+dub) Source both subbed and dubbed episode schedules from AnimeSchedule.net v3 (absolute timestamps, episode numbers, delay windows, streams), keyed to AniList shows by title. Removes SubsPlease and its ~650-line fuzzy matcher. Countdown source is now a setting (native|sub|dub) with a dub->sub->native fallback. Requires ANIMESCHEDULE_CLIENT_TOKEN. --- src/graphql/anime/resolvers.ts | 30 +++++++++++------------------- src/graphql/anime/schema.graphql | 39 +++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 37 deletions(-) (limited to 'src/graphql') diff --git a/src/graphql/anime/resolvers.ts b/src/graphql/anime/resolvers.ts index 577950f7..8d87eb6c 100644 --- a/src/graphql/anime/resolvers.ts +++ b/src/graphql/anime/resolvers.ts @@ -1,31 +1,23 @@ +import { env } from "$env/dynamic/private"; +import { fetchTimetables } from "$lib/Media/Anime/Airing/animeSchedule"; import type { Resolvers as RootResolvers, WithIndex } from "../$types"; type AnimeResolvers = Pick< RootResolvers, - "Query" | "Anime" | "Subtitles" | "SubtitleSchedule" | "Subtitle" + "Query" | "Anime" | "Airing" | "AiringRelease" | "Stream" >; export const resolvers: WithIndex = { Query: { - Anime: async (_, args) => { - const timezone = args.timezone || "Asia/Tokyo"; + Anime: async () => { + const token = env.ANIMESCHEDULE_CLIENT_TOKEN; + const generatedAt = Math.floor(Date.now() / 1000); - return { - subtitles: { - timezone, - schedule: Object.fromEntries( - Object.entries( - ( - await ( - await fetch( - `https://subsplease.org/api/?f=schedule&tz=${timezone}`, - ) - ).json() - ).schedule, - ).map(([key, value]) => [key.toLowerCase(), value]), - ), - }, - }; + if (!token) return { airing: { generatedAt, sub: [], dub: [] } }; + + const { sub, dub } = await fetchTimetables(token); + + return { airing: { generatedAt, sub, dub } }; }, }, }; diff --git a/src/graphql/anime/schema.graphql b/src/graphql/anime/schema.graphql index d5774966..aad7afec 100644 --- a/src/graphql/anime/schema.graphql +++ b/src/graphql/anime/schema.graphql @@ -1,29 +1,32 @@ type Query { - Anime(timezone: String): Anime! + Anime: Anime! } type Anime { - subtitles: Subtitles + airing: Airing } -type Subtitles { - timezone: String - schedule: SubtitleSchedule +type Airing { + generatedAt: Int + sub: [AiringRelease] + dub: [AiringRelease] } -type SubtitleSchedule { - monday: [Subtitle] - tuesday: [Subtitle] - wednesday: [Subtitle] - thursday: [Subtitle] - friday: [Subtitle] - saturday: [Subtitle] - sunday: [Subtitle] +type AiringRelease { + route: String + title: String + romaji: String + english: String + native: String + episodeNumber: Int + airingAt: Int + delayedUntil: Int + imageUrl: String + streams: [Stream] } -type Subtitle { - title: String - page: String - image_url: String - time: String +type Stream { + platform: String + url: String + name: String } -- cgit v1.2.3