feat: make multi sources explicitly configurable
This commit is contained in:
parent
81434fff0e
commit
a0ed13f18e
7 changed files with 22 additions and 9 deletions
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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 [];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 }];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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)",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -36,11 +36,16 @@ export const buildManifest = (sources: Source[], config: Config): ManifestWithCo
|
|||
const countryCodeSources: Partial<Record<CountryCode, Source[]>> = {};
|
||||
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({
|
||||
|
|
|
|||
Loading…
Reference in a new issue