From 00720565b41985c07bd16471108aff16600f258e Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Tue, 8 Apr 2025 08:41:57 -0400 Subject: [PATCH] feat: update Aniwatch provider to include headers --- src/controllers/episodes/getEpisodeUrl/anify.ts | 2 +- src/controllers/episodes/getEpisodeUrl/aniwatch.ts | 10 +++++++--- src/controllers/episodes/getEpisodeUrl/consumet.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/controllers/episodes/getEpisodeUrl/anify.ts b/src/controllers/episodes/getEpisodeUrl/anify.ts index 9a7b83d..7815c19 100644 --- a/src/controllers/episodes/getEpisodeUrl/anify.ts +++ b/src/controllers/episodes/getEpisodeUrl/anify.ts @@ -1,4 +1,5 @@ import { sortByProperty } from "~/libs/sortByProperty"; +import type { FetchUrlResponse } from "~/types/episode/fetch-url-response"; import { type SkipTime, convertSkipTime } from "./convertSkipTime"; import { @@ -6,7 +7,6 @@ import { qualityPriority, subtitlesPriority, } from "./priorities"; -import type { FetchUrlResponse } from "./responseType"; export async function getSourcesFromAnify( provider: string, diff --git a/src/controllers/episodes/getEpisodeUrl/aniwatch.ts b/src/controllers/episodes/getEpisodeUrl/aniwatch.ts index 92305a8..dbdb0fd 100644 --- a/src/controllers/episodes/getEpisodeUrl/aniwatch.ts +++ b/src/controllers/episodes/getEpisodeUrl/aniwatch.ts @@ -1,5 +1,6 @@ +import type { FetchUrlResponse } from "~/types/episode/fetch-url-response"; + import { type SkipTime, convertSkipTime } from "./convertSkipTime"; -import type { FetchUrlResponse } from "./responseType"; export async function getSourcesFromAniwatch( watchId: string, @@ -31,7 +32,7 @@ async function getEpisodeUrl(watchId: string, server?: string) { url += `&server=${encodeURIComponent(server)}`; } - const { source, intro, outro, subtitles } = await fetch(url) + const { source, intro, outro, subtitles, headers } = await fetch(url) .then( (res) => res.json() as Promise<{ @@ -44,7 +45,7 @@ async function getEpisodeUrl(watchId: string, server?: string) { return { source: null }; } - const { intro, outro, sources, tracks } = data; + const { intro, outro, sources, tracks, headers } = data; return { intro: convertSkipTime(intro), outro: convertSkipTime(outro), @@ -52,6 +53,7 @@ async function getEpisodeUrl(watchId: string, server?: string) { subtitles: tracks .filter(({ kind }) => kind === "captions") .map(({ file, label }) => ({ url: file, lang: label ?? "" })), + headers, }; }); @@ -61,6 +63,7 @@ async function getEpisodeUrl(watchId: string, server?: string) { return { source, + headers, intro, outro, subtitles, @@ -87,6 +90,7 @@ async function getEpisodeServers(watchId: string) { } interface AniwatchEpisodeUrlResponse { + headers?: Record; tracks: Track[]; intro: SkipTime; outro: SkipTime; diff --git a/src/controllers/episodes/getEpisodeUrl/consumet.ts b/src/controllers/episodes/getEpisodeUrl/consumet.ts index 6790382..45ca582 100644 --- a/src/controllers/episodes/getEpisodeUrl/consumet.ts +++ b/src/controllers/episodes/getEpisodeUrl/consumet.ts @@ -1,8 +1,8 @@ import { aniList } from "~/consumet"; import { sortByProperty } from "~/libs/sortByProperty"; +import type { FetchUrlResponse } from "~/types/episode/fetch-url-response"; import { qualityPriority, subtitlesPriority } from "./priorities"; -import type { FetchUrlResponse } from "./responseType"; export async function getSourcesFromConsumet( watchId: string,