aboutsummaryrefslogtreecommitdiff
path: root/src/graphql
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-06-05 11:10:22 +0000
committerFuwn <[email protected]>2026-06-05 11:10:22 +0000
commit4b56194ee6807acb56abf0949394efadabf830d4 (patch)
tree5cb2074a8d012bf9b7c900e7e44cbdfd0e15123f /src/graphql
parentfix(lists): tick count down when media leaves a list (diff)
downloaddue.moe-4b56194ee6807acb56abf0949394efadabf830d4.tar.xz
due.moe-4b56194ee6807acb56abf0949394efadabf830d4.zip
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.
Diffstat (limited to 'src/graphql')
-rw-r--r--src/graphql/anime/resolvers.ts30
-rw-r--r--src/graphql/anime/schema.graphql39
2 files changed, 32 insertions, 37 deletions
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<AnimeResolvers> = {
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
}