diff --git a/src/controller/StreamController.ts b/src/controller/StreamController.ts index 904e173..4604685 100644 --- a/src/controller/StreamController.ts +++ b/src/controller/StreamController.ts @@ -1,7 +1,7 @@ import { Request, Response, Router } from 'express'; import winston from 'winston'; import { Source } from '../source'; -import { Config, Context, CountryCode } from '../types'; +import { Config, Context } 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 || countryCode === CountryCode.multi).length); + const sources = this.sources.filter(handler => handler.countryCodes.filter(countryCode => countryCode in ctx.config).length); const { streams, ttl } = await this.streamResolver.resolve(ctx, sources, type, ImdbId.fromString(id)); diff --git a/src/extractor/VixSrc.ts b/src/extractor/VixSrc.ts index 1ccfa3a..d7f599c 100644 --- a/src/extractor/VixSrc.ts +++ b/src/extractor/VixSrc.ts @@ -3,6 +3,7 @@ import { Extractor } from './Extractor'; import { buildMediaFlowProxyExtractorStreamUrl, Fetcher, + hasMultiEnabled, iso639FromCountryCode, supportsMediaFlowProxy, } from '../utils'; @@ -39,7 +40,7 @@ export class VixSrc extends Extractor { const playlistUrl = await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'VixCloud', url); const countryCodes = await this.determineCountryCodesFromPlaylist(ctx, playlistUrl); - if (!countryCodes.some(countryCode => countryCode in ctx.config)) { + if (!hasMultiEnabled(ctx.config) && !countryCodes.some(countryCode => countryCode in ctx.config)) { return []; } diff --git a/src/source/VixSrc.ts b/src/source/VixSrc.ts index c5c5d7e..ee01ce7 100644 --- a/src/source/VixSrc.ts +++ b/src/source/VixSrc.ts @@ -27,6 +27,6 @@ export class VixSrc implements Source { ? new URL(`/tv/${tmdbId.id}/${tmdbId.season}/${tmdbId.episode}`, this.baseUrl) : new URL(`/movie/${tmdbId.id}`, this.baseUrl); - return [{ countryCode: CountryCode.it, url }]; + return [{ countryCode: CountryCode.multi, url }]; }; } diff --git a/src/source/__snapshots__/VixSrc.test.ts.snap b/src/source/__snapshots__/VixSrc.test.ts.snap index 6de845a..2f63036 100644 --- a/src/source/__snapshots__/VixSrc.test.ts.snap +++ b/src/source/__snapshots__/VixSrc.test.ts.snap @@ -3,7 +3,7 @@ exports[`VixSrc handle imdb black mirror s4e2 1`] = ` [ { - "countryCode": "it", + "countryCode": "multi", "url": "https://vixsrc.to/tv/42009/4/2", }, ] @@ -12,7 +12,7 @@ exports[`VixSrc handle imdb black mirror s4e2 1`] = ` exports[`VixSrc handle imdb full metal jacket 1`] = ` [ { - "countryCode": "it", + "countryCode": "multi", "url": "https://vixsrc.to/movie/600", }, ] diff --git a/src/utils/__snapshots__/manifest.test.ts.snap b/src/utils/__snapshots__/manifest.test.ts.snap index 11f0a62..134711a 100644 --- a/src/utils/__snapshots__/manifest.test.ts.snap +++ b/src/utils/__snapshots__/manifest.test.ts.snap @@ -64,6 +64,11 @@ exports[`buildManifest has checked source with appropriate config 1`] = ` exports[`buildManifest has unchecked source without a config 1`] = ` [ + { + "key": "multi", + "title": "Multi 🌐 (VixSrc)", + "type": "checkbox", + }, { "key": "de", "title": "German 🇩🇪 (StreamKiste, MeineCloud)", diff --git a/src/utils/config.ts b/src/utils/config.ts index 0181cbe..40f5f3e 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -1,7 +1,9 @@ import { Config } from '../types'; export const getDefaultConfig = (): Config => { - return { en: 'on' }; + return { multi: 'on', en: 'on' }; }; export const showExternalUrls = (config: Config): boolean => 'includeExternalUrls' in config; + +export const hasMultiEnabled = (config: Config): boolean => 'multi' in config; diff --git a/src/utils/manifest.ts b/src/utils/manifest.ts index 44ba719..6a502f3 100644 --- a/src/utils/manifest.ts +++ b/src/utils/manifest.ts @@ -36,11 +36,16 @@ export const buildManifest = (sources: Source[], config: Config): ManifestWithCo const countryCodeSources: Partial> = {}; sources.forEach(source => source.countryCodes - .filter(countryCode => countryCode !== CountryCode.multi) .forEach(countryCode => countryCodeSources[countryCode] = [...(countryCodeSources[countryCode] ?? []), source])); const sortedLanguageSources = typedEntries(countryCodeSources) - .sort(([countryCodeA], [countryCodeB]) => countryCodeA.localeCompare(countryCodeB)); + .sort(([countryCodeA], [countryCodeB]) => { + if (countryCodeB === CountryCode.multi) { + return 1; + } + + return countryCodeA.localeCompare(countryCodeB); + }); for (const [countryCode, sources] of sortedLanguageSources) { manifest.config.push({