feat: make VixSrc a default multi-language source
This commit is contained in:
parent
c0fc6ff7ea
commit
35e049f577
7 changed files with 16 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { Request, Response, Router } from 'express';
|
||||
import winston from 'winston';
|
||||
import { Source } from '../source';
|
||||
import { Config, Context } from '../types';
|
||||
import { Config, Context, CountryCode } from '../types';
|
||||
import { envIsProd, getDefaultConfig, ImdbId, StreamResolver } from '../utils';
|
||||
import { ContentType } from 'stremio-addon-sdk';
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ export class StreamController {
|
|||
|
||||
this.logger.info(`Search stream for type "${type}" and id "${id}" for ip ${ctx.ip}`, ctx);
|
||||
|
||||
const sources = this.sources.filter(handler => handler.countryCodes.filter(countryCode => countryCode in ctx.config).length);
|
||||
const sources = this.sources.filter(handler => handler.countryCodes.filter(countryCode => countryCode in ctx.config || countryCode === CountryCode.multi).length);
|
||||
|
||||
const { streams, ttl } = await this.streamResolver.resolve(ctx, sources, type, ImdbId.fromString(id));
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ const logger = winston.createLogger({
|
|||
const fetcher = new Fetcher(logger);
|
||||
|
||||
const sources: Source[] = [
|
||||
// multi
|
||||
new VixSrc(fetcher),
|
||||
// EN
|
||||
new Soaper(fetcher),
|
||||
new VidSrc(fetcher),
|
||||
|
|
@ -38,7 +40,6 @@ const sources: Source[] = [
|
|||
// IT
|
||||
new Eurostreaming(fetcher),
|
||||
new MostraGuarda(fetcher),
|
||||
new VixSrc(fetcher),
|
||||
];
|
||||
|
||||
const addon = express();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export class VixSrc implements Source {
|
|||
|
||||
public readonly contentTypes: ContentType[] = ['movie', 'series'];
|
||||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.it];
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.multi];
|
||||
|
||||
private readonly baseUrl = 'https://vixsrc.to';
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export type ManifestWithConfig = Manifest & { config: ManifestConfig[] };
|
|||
export type Config = Partial<Record<CountryCode | 'includeExternalUrls' | 'mediaFlowProxyUrl' | 'mediaFlowProxyPassword', string>>;
|
||||
|
||||
export enum CountryCode {
|
||||
multi = 'multi',
|
||||
de = 'de',
|
||||
en = 'en',
|
||||
es = 'es',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { CountryCode } from '../types';
|
||||
|
||||
const countryCodeMap: Record<CountryCode, { language: string; flag: string; iso639: string }> = {
|
||||
const countryCodeMap: Record<CountryCode, { language: string; flag: string; iso639: string | undefined }> = {
|
||||
multi: { language: 'Multi', flag: '🌐', iso639: undefined },
|
||||
de: { language: 'German', flag: '🇩🇪', iso639: 'ger' },
|
||||
en: { language: 'English', flag: '🇺🇸', iso639: 'eng' },
|
||||
es: { language: 'Castilian Spanish', flag: '🇪🇸', iso639: 'spa' },
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { buildManifest } from './manifest';
|
||||
import { StreamKiste, MeineCloud, VerHdLink } from '../source';
|
||||
import { StreamKiste, MeineCloud, VerHdLink, VixSrc } from '../source';
|
||||
import { FetcherMock } from './FetcherMock';
|
||||
|
||||
const fetcher = new FetcherMock('/dev/null');
|
||||
|
|
@ -7,6 +7,7 @@ const fetcher = new FetcherMock('/dev/null');
|
|||
describe('buildManifest', () => {
|
||||
test('has unchecked source without a config', () => {
|
||||
const sources = [
|
||||
new VixSrc(fetcher),
|
||||
new VerHdLink(fetcher),
|
||||
new StreamKiste(fetcher),
|
||||
new MeineCloud(fetcher),
|
||||
|
|
|
|||
|
|
@ -34,8 +34,12 @@ export const buildManifest = (sources: Source[], config: Config): ManifestWithCo
|
|||
};
|
||||
|
||||
const countryCodeSources: Partial<Record<CountryCode, Source[]>> = {};
|
||||
sources.forEach((handler) => {
|
||||
handler.countryCodes.forEach(countryCode => countryCodeSources[countryCode] = [...(countryCodeSources[countryCode] ?? []), handler]);
|
||||
sources.forEach((source) => {
|
||||
if (source.countryCodes.includes(CountryCode.multi)) {
|
||||
return;
|
||||
}
|
||||
|
||||
source.countryCodes.forEach(countryCode => countryCodeSources[countryCode] = [...(countryCodeSources[countryCode] ?? []), source]);
|
||||
});
|
||||
|
||||
const sortedLanguageSources = typedEntries(countryCodeSources)
|
||||
|
|
|
|||
Loading…
Reference in a new issue