mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 16:53:24 +00:00
Merge branch 'dev' into ridomovies
This commit is contained in:
@@ -31,3 +31,13 @@ export function isValidLanguageCode(code: string | null): boolean {
|
|||||||
if (!code) return false;
|
if (!code) return false;
|
||||||
return ISO6391.validate(code);
|
return ISO6391.validate(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function removeDuplicatedLanguages(list: Caption[]) {
|
||||||
|
const beenSeen: Record<string, true> = {};
|
||||||
|
|
||||||
|
return list.filter((sub) => {
|
||||||
|
if (beenSeen[sub.language]) return false;
|
||||||
|
beenSeen[sub.language] = true;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@@ -1,4 +1,9 @@
|
|||||||
import { Caption, getCaptionTypeFromUrl, isValidLanguageCode } from '@/providers/captions';
|
import {
|
||||||
|
Caption,
|
||||||
|
getCaptionTypeFromUrl,
|
||||||
|
isValidLanguageCode,
|
||||||
|
removeDuplicatedLanguages as removeDuplicateLanguages,
|
||||||
|
} from '@/providers/captions';
|
||||||
import { captionsDomains } from '@/providers/sources/showbox/common';
|
import { captionsDomains } from '@/providers/sources/showbox/common';
|
||||||
import { sendRequest } from '@/providers/sources/showbox/sendRequest';
|
import { sendRequest } from '@/providers/sources/showbox/sendRequest';
|
||||||
import { ScrapeContext } from '@/utils/context';
|
import { ScrapeContext } from '@/utils/context';
|
||||||
@@ -36,8 +41,7 @@ export async function getSubtitles(
|
|||||||
|
|
||||||
const subResult = (await sendRequest(ctx, subtitleApiQuery)) as CaptionApiResponse;
|
const subResult = (await sendRequest(ctx, subtitleApiQuery)) as CaptionApiResponse;
|
||||||
const subtitleList = subResult.data.list;
|
const subtitleList = subResult.data.list;
|
||||||
const output: Caption[] = [];
|
let output: Caption[] = [];
|
||||||
const languagesAdded: Record<string, true> = {};
|
|
||||||
|
|
||||||
subtitleList.forEach((sub) => {
|
subtitleList.forEach((sub) => {
|
||||||
const subtitle = sub.subtitles.sort((a, b) => b.order - a.order)[0];
|
const subtitle = sub.subtitles.sort((a, b) => b.order - a.order)[0];
|
||||||
@@ -56,9 +60,6 @@ export async function getSubtitles(
|
|||||||
const validCode = isValidLanguageCode(subtitle.lang);
|
const validCode = isValidLanguageCode(subtitle.lang);
|
||||||
if (!validCode) return;
|
if (!validCode) return;
|
||||||
|
|
||||||
if (languagesAdded[subtitle.lang]) return;
|
|
||||||
languagesAdded[subtitle.lang] = true;
|
|
||||||
|
|
||||||
output.push({
|
output.push({
|
||||||
id: subtitleFilePath,
|
id: subtitleFilePath,
|
||||||
language: subtitle.lang,
|
language: subtitle.lang,
|
||||||
@@ -68,5 +69,7 @@ export async function getSubtitles(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
output = removeDuplicateLanguages(output);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,6 @@ export const lookmovieScraper = makeSourcerer({
|
|||||||
id: 'lookmovie',
|
id: 'lookmovie',
|
||||||
name: 'LookMovie',
|
name: 'LookMovie',
|
||||||
rank: 1,
|
rank: 1,
|
||||||
disabled: true,
|
|
||||||
flags: [flags.IP_LOCKED],
|
flags: [flags.IP_LOCKED],
|
||||||
scrapeShow: universalScraper,
|
scrapeShow: universalScraper,
|
||||||
scrapeMovie: universalScraper,
|
scrapeMovie: universalScraper,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { MovieMedia, ShowMedia } from '@/entrypoint/utils/media';
|
import { MovieMedia, ShowMedia } from '@/entrypoint/utils/media';
|
||||||
import { Caption } from '@/providers/captions';
|
import { Caption, labelToLanguageCode, removeDuplicatedLanguages } from '@/providers/captions';
|
||||||
import { ScrapeContext } from '@/utils/context';
|
import { ScrapeContext } from '@/utils/context';
|
||||||
|
|
||||||
import { StreamsDataResult } from './type';
|
import { StreamsDataResult } from './type';
|
||||||
@@ -44,13 +44,21 @@ export async function getVideo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const captions: Caption[] = data.subtitles.map((sub) => ({
|
let captions: Caption[] = [];
|
||||||
id: sub.url,
|
|
||||||
type: 'vtt',
|
for (const sub of data.subtitles) {
|
||||||
url: `${baseUrl}${sub.url}`,
|
const language = labelToLanguageCode(sub.language);
|
||||||
hasCorsRestrictions: false,
|
if (!language) continue;
|
||||||
language: sub.language,
|
captions.push({
|
||||||
}));
|
id: sub.url,
|
||||||
|
type: 'vtt',
|
||||||
|
url: `${baseUrl}${sub.url}`,
|
||||||
|
hasCorsRestrictions: false,
|
||||||
|
language,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
captions = removeDuplicatedLanguages(captions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
playlist: videoUrl,
|
playlist: videoUrl,
|
||||||
|
Reference in New Issue
Block a user