aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Media/Anime
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-06-05 13:58:43 +0000
committerFuwn <[email protected]>2026-06-05 13:58:43 +0000
commit83879a0fa01415999116cbc46377b4819fc19f96 (patch)
treea15d2870b29f727923b2dcdc3b5f017dd4575407 /src/lib/Media/Anime
parentfix(schedule): use masonry columns so day panels collapse cleanly (diff)
downloaddue.moe-83879a0fa01415999116cbc46377b4819fc19f96.tar.xz
due.moe-83879a0fa01415999116cbc46377b4819fc19f96.zip
feat(schedule): add native track alongside sub and dub
Source the native (original-language) broadcast schedule from AnimeSchedule's "raw" airType and expose it as a third track on the schedule-page toggle and the GraphQL airing query.
Diffstat (limited to 'src/lib/Media/Anime')
-rw-r--r--src/lib/Media/Anime/Airing/animeSchedule.ts36
-rw-r--r--src/lib/Media/Anime/Airing/classify.test.ts2
2 files changed, 27 insertions, 11 deletions
diff --git a/src/lib/Media/Anime/Airing/animeSchedule.ts b/src/lib/Media/Anime/Airing/animeSchedule.ts
index f3f6f85d..7bfe5ac3 100644
--- a/src/lib/Media/Anime/Airing/animeSchedule.ts
+++ b/src/lib/Media/Anime/Airing/animeSchedule.ts
@@ -1,9 +1,11 @@
// Data model for AnimeSchedule.net's weekly timetable, the source of truth for
-// when subbed and dubbed episodes actually release. Unlike a fansub schedule,
-// every release carries an absolute timestamp, an episode number, delay windows,
-// and the streaming platforms it lands on.
+// when native, subbed, and dubbed episodes actually release. Unlike a fansub
+// schedule, every release carries an absolute timestamp, an episode number,
+// delay windows, and the streaming platforms it lands on.
-export type AirType = "sub" | "dub";
+// A release track. "native" is AnimeSchedule's "raw" (original-language)
+// broadcast; "sub"/"dub" are the localised releases.
+export type AirType = "native" | "sub" | "dub";
export interface Stream {
platform: string;
@@ -25,9 +27,10 @@ export interface AiringEntry {
streams: Stream[];
}
-// The merged sub + dub schedule for the current week.
+// The merged native + sub + dub schedule for the current week.
export interface AiringSchedule {
generatedAt: number;
+ native: AiringEntry[];
sub: AiringEntry[];
dub: AiringEntry[];
}
@@ -91,12 +94,19 @@ export const parseTimetable = (raw: unknown): AiringEntry[] => {
const TIMETABLE_ENDPOINT = "https://animeschedule.net/api/v3/timetables";
-// Fetch and parse the current week's sub and dub timetables in one shot. The
-// caller supplies the AnimeSchedule application token.
+// Fetch and parse the current week's native, sub, and dub timetables in one
+// shot. The caller supplies the AnimeSchedule application token. AnimeSchedule
+// names the native broadcast "raw".
export const fetchTimetables = async (
token: string,
-): Promise<{ sub: AiringEntry[]; dub: AiringEntry[] }> => {
- const fetchOne = async (airType: AirType): Promise<AiringEntry[]> => {
+): Promise<{
+ native: AiringEntry[];
+ sub: AiringEntry[];
+ dub: AiringEntry[];
+}> => {
+ const fetchOne = async (
+ airType: "raw" | "sub" | "dub",
+ ): Promise<AiringEntry[]> => {
try {
const response = await fetch(`${TIMETABLE_ENDPOINT}?airType=${airType}`, {
headers: { Authorization: `Bearer ${token}` },
@@ -108,7 +118,11 @@ export const fetchTimetables = async (
}
};
- const [sub, dub] = await Promise.all([fetchOne("sub"), fetchOne("dub")]);
+ const [native, sub, dub] = await Promise.all([
+ fetchOne("raw"),
+ fetchOne("sub"),
+ fetchOne("dub"),
+ ]);
- return { sub, dub };
+ return { native, sub, dub };
};
diff --git a/src/lib/Media/Anime/Airing/classify.test.ts b/src/lib/Media/Anime/Airing/classify.test.ts
index 1019b303..eeff2036 100644
--- a/src/lib/Media/Anime/Airing/classify.test.ts
+++ b/src/lib/Media/Anime/Airing/classify.test.ts
@@ -16,6 +16,7 @@ import settings from "$stores/settings";
// sub at `airingAt`.
const subScheduleFor = (media: Media, airingAt: number): AiringSchedule => ({
generatedAt: Math.floor(Date.now() / 1000),
+ native: [],
sub: [
{
route: `fixture-${media.id}`,
@@ -196,6 +197,7 @@ describe("countdown source fallback", () => {
const schedule: AiringSchedule = {
generatedAt: Math.floor(Date.now() / 1000),
+ native: [],
sub: [],
dub: [],
};