feat: update Aniwatch provider to include headers
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<string, string>;
|
||||
tracks: Track[];
|
||||
intro: SkipTime;
|
||||
outro: SkipTime;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user