feat: update Aniwatch provider to include headers
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { sortByProperty } from "~/libs/sortByProperty";
|
import { sortByProperty } from "~/libs/sortByProperty";
|
||||||
|
import type { FetchUrlResponse } from "~/types/episode/fetch-url-response";
|
||||||
|
|
||||||
import { type SkipTime, convertSkipTime } from "./convertSkipTime";
|
import { type SkipTime, convertSkipTime } from "./convertSkipTime";
|
||||||
import {
|
import {
|
||||||
@@ -6,7 +7,6 @@ import {
|
|||||||
qualityPriority,
|
qualityPriority,
|
||||||
subtitlesPriority,
|
subtitlesPriority,
|
||||||
} from "./priorities";
|
} from "./priorities";
|
||||||
import type { FetchUrlResponse } from "./responseType";
|
|
||||||
|
|
||||||
export async function getSourcesFromAnify(
|
export async function getSourcesFromAnify(
|
||||||
provider: string,
|
provider: string,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import type { FetchUrlResponse } from "~/types/episode/fetch-url-response";
|
||||||
|
|
||||||
import { type SkipTime, convertSkipTime } from "./convertSkipTime";
|
import { type SkipTime, convertSkipTime } from "./convertSkipTime";
|
||||||
import type { FetchUrlResponse } from "./responseType";
|
|
||||||
|
|
||||||
export async function getSourcesFromAniwatch(
|
export async function getSourcesFromAniwatch(
|
||||||
watchId: string,
|
watchId: string,
|
||||||
@@ -31,7 +32,7 @@ async function getEpisodeUrl(watchId: string, server?: string) {
|
|||||||
url += `&server=${encodeURIComponent(server)}`;
|
url += `&server=${encodeURIComponent(server)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { source, intro, outro, subtitles } = await fetch(url)
|
const { source, intro, outro, subtitles, headers } = await fetch(url)
|
||||||
.then(
|
.then(
|
||||||
(res) =>
|
(res) =>
|
||||||
res.json() as Promise<{
|
res.json() as Promise<{
|
||||||
@@ -44,7 +45,7 @@ async function getEpisodeUrl(watchId: string, server?: string) {
|
|||||||
return { source: null };
|
return { source: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
const { intro, outro, sources, tracks } = data;
|
const { intro, outro, sources, tracks, headers } = data;
|
||||||
return {
|
return {
|
||||||
intro: convertSkipTime(intro),
|
intro: convertSkipTime(intro),
|
||||||
outro: convertSkipTime(outro),
|
outro: convertSkipTime(outro),
|
||||||
@@ -52,6 +53,7 @@ async function getEpisodeUrl(watchId: string, server?: string) {
|
|||||||
subtitles: tracks
|
subtitles: tracks
|
||||||
.filter(({ kind }) => kind === "captions")
|
.filter(({ kind }) => kind === "captions")
|
||||||
.map(({ file, label }) => ({ url: file, lang: label ?? "" })),
|
.map(({ file, label }) => ({ url: file, lang: label ?? "" })),
|
||||||
|
headers,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ async function getEpisodeUrl(watchId: string, server?: string) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
source,
|
source,
|
||||||
|
headers,
|
||||||
intro,
|
intro,
|
||||||
outro,
|
outro,
|
||||||
subtitles,
|
subtitles,
|
||||||
@@ -87,6 +90,7 @@ async function getEpisodeServers(watchId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AniwatchEpisodeUrlResponse {
|
interface AniwatchEpisodeUrlResponse {
|
||||||
|
headers?: Record<string, string>;
|
||||||
tracks: Track[];
|
tracks: Track[];
|
||||||
intro: SkipTime;
|
intro: SkipTime;
|
||||||
outro: SkipTime;
|
outro: SkipTime;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { aniList } from "~/consumet";
|
import { aniList } from "~/consumet";
|
||||||
import { sortByProperty } from "~/libs/sortByProperty";
|
import { sortByProperty } from "~/libs/sortByProperty";
|
||||||
|
import type { FetchUrlResponse } from "~/types/episode/fetch-url-response";
|
||||||
|
|
||||||
import { qualityPriority, subtitlesPriority } from "./priorities";
|
import { qualityPriority, subtitlesPriority } from "./priorities";
|
||||||
import type { FetchUrlResponse } from "./responseType";
|
|
||||||
|
|
||||||
export async function getSourcesFromConsumet(
|
export async function getSourcesFromConsumet(
|
||||||
watchId: string,
|
watchId: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user