refactor: fully replace handler with source

This commit is contained in:
WebStreamr 2025-08-17 18:21:56 +00:00
parent 73627fbf0d
commit 176c4c93e7
No known key found for this signature in database
22 changed files with 121 additions and 121 deletions

View file

@ -33,7 +33,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(source => source.countryCodes.filter(countryCode => countryCode in ctx.config).length);
let mutex = locks.get(id);
if (!mutex) {

View file

@ -5,32 +5,32 @@ import { CineHDPlus } from './CineHDPlus';
const ctx = createTestContext({ es: 'on', mx: 'on' });
describe('CineHDPlus', () => {
let handler: CineHDPlus;
let source: CineHDPlus;
beforeEach(() => {
handler = new CineHDPlus(new FetcherMock(`${__dirname}/__fixtures__/CineHDPlus`));
source = new CineHDPlus(new FetcherMock(`${__dirname}/__fixtures__/CineHDPlus`));
});
test('handles non-existent series gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
const streams = await source.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
expect(streams).toHaveLength(0);
});
test('handle imdb black mirror s2e3 (mx)', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 2, 3));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 2, 3));
expect(streams).toMatchSnapshot();
});
test('handle imdb babylon 5 s2e3 (es)', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt0105946', 2, 3));
const streams = await source.handle(ctx, 'series', new ImdbId('tt0105946', 2, 3));
expect(streams).toMatchSnapshot();
});
test('does not return mx results for es and vice-versa', async () => {
const streamsEs = await handler.handle({ ...ctx, ...{ config: { es: 'on' } } }, 'series', new ImdbId('tt2085059', 2, 3));
const streamsEs = await source.handle({ ...ctx, ...{ config: { es: 'on' } } }, 'series', new ImdbId('tt2085059', 2, 3));
expect(streamsEs).toHaveLength(0);
const streamsMx = await handler.handle({ ...ctx, ...{ config: { mx: 'on' } } }, 'series', new ImdbId('tt0105946', 2, 3));
const streamsMx = await source.handle({ ...ctx, ...{ config: { mx: 'on' } } }, 'series', new ImdbId('tt0105946', 2, 3));
expect(streamsMx).toHaveLength(0);
});
});

View file

@ -5,44 +5,44 @@ import { Cuevana } from './Cuevana';
const ctx = createTestContext({ es: 'on', mx: 'on' });
describe('Cuevana', () => {
let handler: Cuevana;
let source: Cuevana;
beforeEach(() => {
handler = new Cuevana(new FetcherMock(`${__dirname}/__fixtures__/Cuevana`));
source = new Cuevana(new FetcherMock(`${__dirname}/__fixtures__/Cuevana`));
});
test('handles non-existent series gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(61945, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(61945, 1, 1));
expect(streams).toHaveLength(0);
});
test('handles non-existent episodes gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(1402, 1, 99));
const streams = await source.handle(ctx, 'series', new TmdbId(1402, 1, 99));
expect(streams).toHaveLength(0);
});
test('handle walking dead s1e1', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(1402, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(1402, 1, 1));
expect(streams).toMatchSnapshot();
});
test('handle la frontera s1e1', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(274980, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(274980, 1, 1));
expect(streams).toMatchSnapshot();
});
test('handle el camino', async () => {
const streams = await handler.handle(ctx, 'movie', new TmdbId(559969, undefined, undefined));
const streams = await source.handle(ctx, 'movie', new TmdbId(559969, undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('does not return mx content for es', async () => {
const streams = await handler.handle(createTestContext({ es: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
const streams = await source.handle(createTestContext({ es: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('does not return es content for mx', async () => {
const streams = await handler.handle(createTestContext({ mx: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
const streams = await source.handle(createTestContext({ mx: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,34 +5,34 @@ import { Eurostreaming } from './Eurostreaming';
const ctx = createTestContext({ it: 'on' });
describe('Eurostreaming', () => {
let handler: Eurostreaming;
let source: Eurostreaming;
beforeEach(() => {
handler = new Eurostreaming(new FetcherMock(`${__dirname}/__fixtures__/Eurostreaming`));
source = new Eurostreaming(new FetcherMock(`${__dirname}/__fixtures__/Eurostreaming`));
});
test('handles non-existent series gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(61945, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(61945, 1, 1));
expect(streams).toHaveLength(0);
});
test('handle imdb black mirror s2e4', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(42009, 2, 4));
const streams = await source.handle(ctx, 'series', new TmdbId(42009, 2, 4));
expect(streams).toMatchSnapshot();
});
test('handle lost s1e1', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(4607, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(4607, 1, 1));
expect(streams).toMatchSnapshot();
});
test('last of us s1e1', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(100088, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(100088, 1, 1));
expect(streams).toMatchSnapshot();
});
test('game of thrones s1e1', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(1399, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(1399, 1, 1));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,24 +5,24 @@ import { Frembed } from './Frembed';
const ctx = createTestContext({ fr: 'on' });
describe('Frembed', () => {
let handler: Frembed;
let source: Frembed;
beforeEach(() => {
handler = new Frembed(new FetcherMock(`${__dirname}/__fixtures__/Frembed`));
source = new Frembed(new FetcherMock(`${__dirname}/__fixtures__/Frembed`));
});
test('handle imdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
expect(streams).toMatchSnapshot();
});
test('handle tmdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(42009, 4, 2));
const streams = await source.handle(ctx, 'series', new TmdbId(42009, 4, 2));
expect(streams).toMatchSnapshot();
});
test('handle battle royal', async () => {
const streams = await handler.handle(ctx, 'movie', new TmdbId(3176, undefined, undefined));
const streams = await source.handle(ctx, 'movie', new TmdbId(3176, undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { FrenchCloud } from './FrenchCloud';
const ctx = createTestContext({ fr: 'on' });
describe('FrenchCloud', () => {
let handler: FrenchCloud;
let source: FrenchCloud;
beforeEach(() => {
handler = new FrenchCloud(new FetcherMock(`${__dirname}/__fixtures__/FrenchCloud`));
source = new FrenchCloud(new FetcherMock(`${__dirname}/__fixtures__/FrenchCloud`));
});
test('handles non-existent movies gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle imdb the devil\'s bath', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt29141112', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt29141112', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,39 +5,39 @@ import { HomeCine } from './HomeCine';
const ctx = createTestContext({ es: 'on', mx: 'on' });
describe('HomeCine', () => {
let handler: HomeCine;
let source: HomeCine;
beforeEach(() => {
handler = new HomeCine(new FetcherMock(`${__dirname}/__fixtures__/HomeCine`));
source = new HomeCine(new FetcherMock(`${__dirname}/__fixtures__/HomeCine`));
});
test('handles non-uploaded movie gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(3176, undefined, undefined));
const streams = await source.handle(ctx, 'series', new TmdbId(3176, undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handles non-existent episodes gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(1402, 1, 99));
const streams = await source.handle(ctx, 'series', new TmdbId(1402, 1, 99));
expect(streams).toHaveLength(0);
});
test('handle walking dead s1e1', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(1402, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(1402, 1, 1));
expect(streams).toMatchSnapshot();
});
test('handle el camino', async () => {
const streams = await handler.handle(ctx, 'movie', new TmdbId(559969, undefined, undefined));
const streams = await source.handle(ctx, 'movie', new TmdbId(559969, undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('does not return mx content for es', async () => {
const streams = await handler.handle(createTestContext({ es: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
const streams = await source.handle(createTestContext({ es: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('does not return es content for mx', async () => {
const streams = await handler.handle(createTestContext({ mx: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
const streams = await source.handle(createTestContext({ mx: 'on' }), 'movie', new TmdbId(559969, undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,44 +5,44 @@ import { KinoGer } from './KinoGer';
const ctx = createTestContext({ de: 'on' });
describe('KinoGer', () => {
let handler: KinoGer;
let source: KinoGer;
beforeEach(() => {
handler = new KinoGer(new FetcherMock(`${__dirname}/__fixtures__/KinoGer`));
source = new KinoGer(new FetcherMock(`${__dirname}/__fixtures__/KinoGer`));
});
test('handles non-existent movies gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle non-existent episode gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 99, 99));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 99, 99));
expect(streams).toHaveLength(0);
});
test('handle imdb dead city s2e5', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt18546730', 2, 5));
const streams = await source.handle(ctx, 'series', new ImdbId('tt18546730', 2, 5));
expect(streams).toMatchSnapshot();
});
test('handle imdb dead city s2e6', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt18546730', 2, 6));
const streams = await source.handle(ctx, 'series', new ImdbId('tt18546730', 2, 6));
expect(streams).toMatchSnapshot();
});
test('handle missing episode imdb black mirror s3e4', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 3, 4));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 3, 4));
expect(streams).toMatchSnapshot();
});
test('handle no fsst via brokeback mountain', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt0388795', undefined, undefined));
const streams = await source.handle(ctx, 'series', new ImdbId('tt0388795', undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('handle imdb blood and sinners', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt31193180', undefined, undefined));
const streams = await source.handle(ctx, 'series', new ImdbId('tt31193180', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { MegaKino } from './MegaKino';
const ctx = createTestContext({ de: 'on' });
describe('MegaKino', () => {
let handler: MegaKino;
let source: MegaKino;
beforeEach(() => {
handler = new MegaKino(new FetcherMock(`${__dirname}/__fixtures__/MegaKino`));
source = new MegaKino(new FetcherMock(`${__dirname}/__fixtures__/MegaKino`));
});
test('handles non-existent movies gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle imdb baymax', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt2245084', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt2245084', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { MeineCloud } from './MeineCloud';
const ctx = createTestContext({ de: 'on' });
describe('MeineCloud', () => {
let handler: MeineCloud;
let source: MeineCloud;
beforeEach(() => {
handler = new MeineCloud(new FetcherMock(`${__dirname}/__fixtures__/MeineCloud`));
source = new MeineCloud(new FetcherMock(`${__dirname}/__fixtures__/MeineCloud`));
});
test('handles non-existent movies gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle imdb the devil\'s bath', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt29141112', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt29141112', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { MostraGuarda } from './MostraGuarda';
const ctx = createTestContext({ it: 'on' });
describe('MostraGuarda', () => {
let handler: MostraGuarda;
let source: MostraGuarda;
beforeEach(() => {
handler = new MostraGuarda(new FetcherMock(`${__dirname}/__fixtures__/MostraGuarda`));
source = new MostraGuarda(new FetcherMock(`${__dirname}/__fixtures__/MostraGuarda`));
});
test('handles non-existent movies gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle imdb the devil\'s bath', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt29141112', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt29141112', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,29 +5,29 @@ import { Movix } from './Movix';
const ctx = createTestContext({ fr: 'on' });
describe('Movix', () => {
let handler: Movix;
let source: Movix;
beforeEach(() => {
handler = new Movix(new FetcherMock(`${__dirname}/__fixtures__/Movix`));
source = new Movix(new FetcherMock(`${__dirname}/__fixtures__/Movix`));
});
test('handles non-existent show gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(46080, 1, 999));
const streams = await source.handle(ctx, 'series', new TmdbId(46080, 1, 999));
expect(streams).toMatchSnapshot();
});
test('handles non-existent movie gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(548473, undefined, undefined));
const streams = await source.handle(ctx, 'series', new TmdbId(548473, undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('handle tmdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(42009, 4, 2));
const streams = await source.handle(ctx, 'series', new TmdbId(42009, 4, 2));
expect(streams).toMatchSnapshot();
});
test('handle battle royal', async () => {
const streams = await handler.handle(ctx, 'movie', new TmdbId(3176, undefined, undefined));
const streams = await source.handle(ctx, 'movie', new TmdbId(3176, undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,33 +5,33 @@ import { PrimeWire } from './PrimeWire';
const ctx = createTestContext({ en: 'on' });
describe('PrimeWire', () => {
let handler: PrimeWire;
let source: PrimeWire;
beforeEach(() => {
handler = new PrimeWire(new FetcherMock(`${__dirname}/__fixtures__/PrimeWire`));
source = new PrimeWire(new FetcherMock(`${__dirname}/__fixtures__/PrimeWire`));
});
test('handle non-existent movie gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle non-existent episode gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt18546730', 99, 99));
const streams = await source.handle(ctx, 'series', new ImdbId('tt18546730', 99, 99));
expect(streams).toHaveLength(0);
});
test('handle imdb dead city s2e5', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt18546730', 2, 5));
const streams = await source.handle(ctx, 'series', new ImdbId('tt18546730', 2, 5));
expect(streams).toMatchSnapshot();
});
test('handle el camino', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt9243946', undefined, undefined));
const streams = await source.handle(ctx, 'series', new ImdbId('tt9243946', undefined, undefined));
expect(streams).toMatchSnapshot();
// Should be using the redirectUrlCache
const streams2 = await handler.handle(ctx, 'series', new ImdbId('tt9243946', undefined, undefined));
const streams2 = await source.handle(ctx, 'series', new ImdbId('tt9243946', undefined, undefined));
expect(streams2).toMatchSnapshot();
});
});

View file

@ -5,44 +5,44 @@ import { Soaper } from './Soaper';
const ctx = createTestContext();
describe('Soaper', () => {
let handler: Soaper;
let source: Soaper;
beforeEach(() => {
handler = new Soaper(new FetcherMock(`${__dirname}/__fixtures__/Soaper`));
source = new Soaper(new FetcherMock(`${__dirname}/__fixtures__/Soaper`));
});
test('handles non-existent movies gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle non-uploaded movie gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt29141112', undefined, undefined));
const streams = await source.handle(ctx, 'series', new ImdbId('tt29141112', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle non-existent episode gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 99, 99));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 99, 99));
expect(streams).toHaveLength(0);
});
test('handle imdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
expect(streams).toMatchSnapshot();
});
test('handle tmdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(42009, 4, 2));
const streams = await source.handle(ctx, 'series', new TmdbId(42009, 4, 2));
expect(streams).toMatchSnapshot();
});
test('handle imdb full metal jacket', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt0093058', undefined, undefined));
const streams = await source.handle(ctx, 'series', new ImdbId('tt0093058', undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('handle lego heroes flash', async () => {
const streams = await handler.handle(ctx, 'movie', new TmdbId(504997, undefined, undefined));
const streams = await source.handle(ctx, 'movie', new TmdbId(504997, undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { StreamKiste } from './StreamKiste';
const ctx = createTestContext({ de: 'on' });
describe('StreamKiste', () => {
let handler: StreamKiste;
let source: StreamKiste;
beforeEach(() => {
handler = new StreamKiste(new FetcherMock(`${__dirname}/__fixtures__/StreamKiste`));
source = new StreamKiste(new FetcherMock(`${__dirname}/__fixtures__/StreamKiste`));
});
test('handles non-existent series gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
const streams = await source.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
expect(streams).toHaveLength(0);
});
test('handle imdb black mirror s2e4', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 2, 4));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 2, 4));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { VerHdLink } from './VerHdLink';
const ctx = createTestContext({ es: 'on', mx: 'on' });
describe('VerHdLink', () => {
let handler: VerHdLink;
let source: VerHdLink;
beforeEach(() => {
handler = new VerHdLink(new FetcherMock(`${__dirname}/__fixtures__/VerHdLink`));
source = new VerHdLink(new FetcherMock(`${__dirname}/__fixtures__/VerHdLink`));
});
test('handles non-existent movies gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle titanic', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt0120338', undefined, undefined));
const streams = await source.handle(ctx, 'movie', new ImdbId('tt0120338', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { VidSrc } from './VidSrc';
const ctx = createTestContext();
describe('VidSrc', () => {
let handler: VidSrc;
let source: VidSrc;
beforeEach(() => {
handler = new VidSrc(new FetcherMock('/dev/null'));
source = new VidSrc(new FetcherMock('/dev/null'));
});
test('handle imdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
expect(streams).toMatchSnapshot();
});
test('handle imdb full metal jacket', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt0093058', undefined, undefined));
const streams = await source.handle(ctx, 'series', new ImdbId('tt0093058', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { VixSrc } from './VixSrc';
const ctx = createTestContext();
describe('VixSrc', () => {
let handler: VixSrc;
let source: VixSrc;
beforeEach(() => {
handler = new VixSrc(new FetcherMock(`${__dirname}/__fixtures__/VixSrc`));
source = new VixSrc(new FetcherMock(`${__dirname}/__fixtures__/VixSrc`));
});
test('handle imdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2));
expect(streams).toMatchSnapshot();
});
test('handle imdb full metal jacket', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt0093058', undefined, undefined));
const streams = await source.handle(ctx, 'series', new ImdbId('tt0093058', undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -5,19 +5,19 @@ import { XPrime } from './XPrime';
const ctx = createTestContext();
describe('XPrime', () => {
let handler: XPrime;
let source: XPrime;
beforeEach(() => {
handler = new XPrime(new FetcherMock(`${__dirname}/__fixtures__/XPrime`));
source = new XPrime(new FetcherMock(`${__dirname}/__fixtures__/XPrime`));
});
test('handle alien: earth 1x1', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(157239, 1, 1));
const streams = await source.handle(ctx, 'series', new TmdbId(157239, 1, 1));
expect(streams).toMatchSnapshot();
});
test('handle superman', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(1061474, undefined, undefined));
const streams = await source.handle(ctx, 'series', new TmdbId(1061474, undefined, undefined));
expect(streams).toMatchSnapshot();
});
});

View file

@ -69,10 +69,10 @@ describe('resolve', () => {
});
test('adds error info', async () => {
class MockHandler implements Source {
public readonly id = 'mockhandler';
class MockSource implements Source {
public readonly id = 'mocksource';
public readonly label = 'MockHandler';
public readonly label = 'MockSource';
public readonly contentTypes: ContentType[] = ['movie'];
@ -240,17 +240,17 @@ describe('resolve', () => {
const streamResolver = new StreamResolver(logger, new ExtractorRegistry(logger, [new MockExtractor()]));
const streams = await streamResolver.resolve(ctx, [new MockHandler()], 'movie', new ImdbId('tt11655566', undefined, undefined));
const streams = await streamResolver.resolve(ctx, [new MockSource()], 'movie', new ImdbId('tt11655566', undefined, undefined));
expect(streams).toMatchSnapshot();
const streamsWithShowErrors = await streamResolver.resolve({ ...ctx, config: { ...ctx.config, showErrors: 'on' } }, [new MockHandler()], 'movie', new ImdbId('tt11655566', undefined, undefined));
const streamsWithShowErrors = await streamResolver.resolve({ ...ctx, config: { ...ctx.config, showErrors: 'on' } }, [new MockSource()], 'movie', new ImdbId('tt11655566', undefined, undefined));
expect(streamsWithShowErrors).toMatchSnapshot();
});
test('ignores not found errors', async () => {
const mockHandler: Source = {
id: 'mockhandler',
label: 'MockHandler',
const mockSource: Source = {
id: 'mocksource',
label: 'MockSource',
contentTypes: ['movie'],
countryCodes: [CountryCode.de],
baseUrl: 'https://example.com',
@ -258,7 +258,7 @@ describe('resolve', () => {
};
const streamResolver = new StreamResolver(logger, new ExtractorRegistry(logger, createExtractors(fetcher)));
const streams = await streamResolver.resolve(ctx, [mockHandler], 'movie', new ImdbId('tt12345678', undefined, undefined));
const streams = await streamResolver.resolve(ctx, [mockSource], 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toMatchSnapshot();
});

View file

@ -39,9 +39,9 @@ export class StreamResolver {
const streams: Stream[] = [];
let handlerErrorOccurred = false;
let sourceErrorOccurred = false;
const urlResults: UrlResult[] = [];
const handlerPromises = sources.map(async (source) => {
const sourcePromises = sources.map(async (source) => {
if (!source.contentTypes.includes(type)) {
return;
}
@ -50,17 +50,17 @@ export class StreamResolver {
const sourceResults = await source.handle(ctx, type, id);
this.logger.info(`${source.id} returned ${sourceResults.length} urls`, ctx);
const handlerUrlResults = await Promise.all(
const sourceUrlResults = await Promise.all(
sourceResults.map(({ countryCode, title, url }) => this.extractorRegistry.handle(ctx, url, countryCode, title)),
);
urlResults.push(...handlerUrlResults.flat());
urlResults.push(...sourceUrlResults.flat());
} catch (error) {
if (error instanceof NotFoundError) {
return;
}
handlerErrorOccurred = true;
sourceErrorOccurred = true;
if (showErrors(ctx.config)) {
streams.push({
@ -71,7 +71,7 @@ export class StreamResolver {
}
}
});
await Promise.all(handlerPromises);
await Promise.all(sourcePromises);
urlResults.sort((a, b) => {
const heightComparison = (b.meta.height ?? 0) - (a.meta.height ?? 0);
@ -115,7 +115,7 @@ export class StreamResolver {
})),
);
const ttl = !handlerErrorOccurred ? this.determineTtl(urlResults) : undefined;
const ttl = !sourceErrorOccurred ? this.determineTtl(urlResults) : undefined;
return {
streams,

View file

@ -56,7 +56,7 @@ export const buildManifest = (sources: Source[], extractors: Extractor[], config
manifest.config.push({
key: countryCode,
type: 'checkbox',
title: `${language} ${flagFromCountryCode(countryCode)} (${(sources as Source[]).map(handler => handler.label).sort().join(', ')})`,
title: `${language} ${flagFromCountryCode(countryCode)} (${(sources as Source[]).map(source => source.label).sort().join(', ')})`,
...(countryCode in config && { default: 'checked' }),
});
}