feat: add Japanese and Korean to languages for VixSrc

This commit is contained in:
WebStreamr 2025-07-01 15:46:30 +00:00
parent bf2187bbbd
commit 81434fff0e
No known key found for this signature in database
5 changed files with 7 additions and 26 deletions

View file

@ -3,7 +3,6 @@ import { Extractor } from './Extractor';
import {
buildMediaFlowProxyExtractorStreamUrl,
Fetcher,
getCountryCodes,
iso639FromCountryCode,
supportsMediaFlowProxy,
} from '../utils';
@ -66,7 +65,7 @@ export class VixSrc extends Extractor {
const countryCodes: CountryCode[] = [CountryCode.it];
getCountryCodes(ctx.config).forEach((countryCode) => {
(Object.keys(CountryCode) as CountryCode[]).forEach((countryCode) => {
const iso639 = iso639FromCountryCode(countryCode);
if (!countryCodes.includes(countryCode) && (new RegExp(`#EXT-X-MEDIA:TYPE=AUDIO.*LANGUAGE="${iso639}"`)).test(playlist)) {

View file

@ -18,6 +18,8 @@ export enum CountryCode {
es = 'es',
fr = 'fr',
it = 'it',
ja = 'ja',
ko = 'ko',
mx = 'mx',
}

View file

@ -1,13 +1,7 @@
import { getCountryCodes, getDefaultConfig } from './config';
import { getDefaultConfig } from './config';
describe('getDefaultConfig', () => {
test('has English enabled', () => {
expect(getDefaultConfig().en).toBe('on');
});
});
describe('getCountryCodes', () => {
test('returns only all country codes', () => {
expect(getCountryCodes({ de: 'on', en: 'on', includeExternalUrls: 'on' })).toStrictEqual(['de', 'en']);
});
});

View file

@ -1,23 +1,7 @@
import { Config, CountryCode } from '../types';
import { Config } from '../types';
export const getDefaultConfig = (): Config => {
return { en: 'on' };
};
const isCountryCode = (key: string): key is CountryCode => {
return Object.values(CountryCode).includes(key as CountryCode);
};
export const getCountryCodes = (config: Config): CountryCode[] => {
const countryCodes: CountryCode[] = [];
for (const key in config) {
if (isCountryCode(key)) {
countryCodes.push(key);
}
}
return countryCodes;
};
export const showExternalUrls = (config: Config): boolean => 'includeExternalUrls' in config;

View file

@ -7,6 +7,8 @@ const countryCodeMap: Record<CountryCode, { language: string; flag: string; iso6
es: { language: 'Castilian Spanish', flag: '🇪🇸', iso639: 'spa' },
fr: { language: 'French', flag: '🇫🇷', iso639: 'fra' },
it: { language: 'Italian', flag: '🇮🇹', iso639: 'ita' },
ja: { language: 'Japanese', flag: '🇯🇵', iso639: 'jpn' },
ko: { language: 'Korean', flag: '🇰🇷', iso639: 'kor' },
mx: { language: 'Latin American Spanish', flag: '🇲🇽', iso639: 'spa' },
};