mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 13:03:25 +00:00
add linked subs to superstream
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import { Caption } from '@/providers/captions';
|
import { Caption, getCaptionTypeFromUrl } from '@/providers/captions';
|
||||||
import { sendRequest } from '@/providers/sources/superstream/sendRequest';
|
import { sendRequest } from '@/providers/sources/superstream/sendRequest';
|
||||||
import { ScrapeContext } from '@/utils/context';
|
import { ScrapeContext } from '@/utils/context';
|
||||||
|
|
||||||
interface CaptionApiResponse {
|
interface CaptionApiResponse {
|
||||||
data: {
|
data: {
|
||||||
list: {
|
list: {
|
||||||
language: string;
|
|
||||||
subtitles: {
|
subtitles: {
|
||||||
|
order: number;
|
||||||
|
lang: string;
|
||||||
file_path: string;
|
file_path: string;
|
||||||
}[];
|
}[];
|
||||||
}[];
|
}[];
|
||||||
@@ -31,7 +32,23 @@ export async function getSubtitles(
|
|||||||
season: seasonId?.toString(),
|
season: seasonId?.toString(),
|
||||||
group: episodeId ? '' : undefined,
|
group: episodeId ? '' : undefined,
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
const _subtitleList = ((await sendRequest(ctx, subtitleApiQuery)) as CaptionApiResponse).data.list;
|
const subtitleList = ((await sendRequest(ctx, subtitleApiQuery)) as CaptionApiResponse).data.list;
|
||||||
return [];
|
const output: Caption[] = [];
|
||||||
|
|
||||||
|
subtitleList.forEach((sub) => {
|
||||||
|
const subtitle = sub.subtitles.sort((a, b) => a.order - b.order)[0];
|
||||||
|
if (!subtitle) return;
|
||||||
|
const subtitleType = getCaptionTypeFromUrl(subtitle.file_path);
|
||||||
|
if (!subtitleType) return;
|
||||||
|
|
||||||
|
output.push({
|
||||||
|
language: subtitle.lang,
|
||||||
|
hasCorsRestrictions: true,
|
||||||
|
type: subtitleType,
|
||||||
|
url: subtitle.file_path,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user