feat: add Amvstrm as provider for stream URL
Summary: Test Plan:
This commit is contained in:
75
src/controllers/episodes/getEpisodeUrl/amvstrm.ts
Normal file
75
src/controllers/episodes/getEpisodeUrl/amvstrm.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import type { FetchUrlResponse } from "./responseType";
|
||||
|
||||
export async function getSourcesFromAmvstrm(
|
||||
watchId: string,
|
||||
): Promise<FetchUrlResponse | null> {
|
||||
const source = await fetch(
|
||||
`https://api-amvstrm.nyt92.eu.org/api/v2/stream/${watchId}`,
|
||||
)
|
||||
.then((res) => res.json<AmvstrmStreamResponse>())
|
||||
.then(({ stream }) => {
|
||||
const streamObj = stream?.multi;
|
||||
if (!!streamObj) {
|
||||
return streamObj.main ?? streamObj.backup;
|
||||
}
|
||||
})
|
||||
.then((streamObj) => streamObj?.url);
|
||||
|
||||
if (!source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
source,
|
||||
subtitles: [],
|
||||
audio: [],
|
||||
};
|
||||
}
|
||||
|
||||
interface AmvstrmStreamResponse {
|
||||
code: number;
|
||||
message: string;
|
||||
info: Info;
|
||||
stream: Stream;
|
||||
iframe: Iframe[];
|
||||
plyr: Nspl;
|
||||
nspl: Nspl;
|
||||
}
|
||||
|
||||
interface Iframe {
|
||||
name: string;
|
||||
iframe: string;
|
||||
}
|
||||
|
||||
interface Info {
|
||||
title: string;
|
||||
id: string;
|
||||
episode: string;
|
||||
}
|
||||
|
||||
interface Nspl {
|
||||
main: string;
|
||||
backup: string;
|
||||
}
|
||||
|
||||
interface Stream {
|
||||
multi: Multi;
|
||||
tracks: Tracks;
|
||||
}
|
||||
|
||||
interface Multi {
|
||||
main: Backup;
|
||||
backup: Backup;
|
||||
}
|
||||
|
||||
interface Backup {
|
||||
url: string;
|
||||
label: string;
|
||||
isM3U8: boolean;
|
||||
quality: string;
|
||||
}
|
||||
|
||||
interface Tracks {
|
||||
file: string;
|
||||
kind: string;
|
||||
}
|
||||
Reference in New Issue
Block a user