mirror of
https://github.com/p-stream/providers.git
synced 2026-05-16 04:53:11 +00:00
30 lines
725 B
TypeScript
30 lines
725 B
TypeScript
import { Caption, removeDuplicatedLanguages } from '@/providers/captions';
|
||
|
||
import { Subtitle } from './types';
|
||
|
||
export async function getCaptions(data: Subtitle[]) {
|
||
let captions: Caption[] = [];
|
||
for (const subtitle of data) {
|
||
let language = '';
|
||
|
||
if (subtitle.name.includes('Рус')) {
|
||
language = 'ru';
|
||
} else if (subtitle.name.includes('Укр')) {
|
||
language = 'uk';
|
||
} else if (subtitle.name.includes('Eng')) {
|
||
language = 'en';
|
||
} else {
|
||
continue;
|
||
}
|
||
|
||
captions.push({
|
||
id: subtitle.url,
|
||
url: subtitle.url,
|
||
language,
|
||
type: 'vtt',
|
||
hasCorsRestrictions: false,
|
||
});
|
||
}
|
||
captions = removeDuplicatedLanguages(captions);
|
||
return captions;
|
||
}
|