refactor(handler): also pass content type to handle()
This commit is contained in:
parent
281cba8da1
commit
956ba68550
16 changed files with 31 additions and 31 deletions
|
|
@ -13,19 +13,19 @@ const ctx: Context = { ip: '127.0.0.1' };
|
|||
|
||||
describe('CineHDPlus', () => {
|
||||
test('does not handle non imdb series', async () => {
|
||||
const streams = await handler.handle(ctx, 'kitsu:123');
|
||||
const streams = await handler.handle(ctx, 'series', 'kitsu:123');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handles non-existent series gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'tt12345678:1:1');
|
||||
const streams = await handler.handle(ctx, 'series', 'tt12345678:1:1');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle imdb black mirror s2e3 (mx)', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt2085059:2:3')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'series', 'tt2085059:2:3')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(2);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
@ -49,7 +49,7 @@ describe('CineHDPlus', () => {
|
|||
});
|
||||
|
||||
test('handle imdb babylon 5 s2e3 (es)', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt0105946:2:3')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'series', 'tt0105946:2:3')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(2);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class CineHDPlus implements Handler {
|
|||
this.embedExtractors = embedExtractors;
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, id: string) => {
|
||||
readonly handle = async (ctx: Context, _type: string, id: string) => {
|
||||
if (!id.startsWith('tt')) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ const ctx: Context = { ip: '127.0.0.1' };
|
|||
|
||||
describe('Eurostreaming', () => {
|
||||
test('does not handle non imdb series', async () => {
|
||||
const streams = await handler.handle(ctx, 'kitsu:123');
|
||||
const streams = await handler.handle(ctx, 'series', 'kitsu:123');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handles non-existent series gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'tt12345678:1:1');
|
||||
const streams = await handler.handle(ctx, 'series', 'tt12345678:1:1');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle imdb black mirror s2e4', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt2085059:2:4')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'series', 'tt2085059:2:4')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(2);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class Eurostreaming implements Handler {
|
|||
this.embedExtractors = embedExtractors;
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, id: string) => {
|
||||
readonly handle = async (ctx: Context, _type: string, id: string) => {
|
||||
if (!id.startsWith('tt')) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ const ctx: Context = { ip: '127.0.0.1' };
|
|||
|
||||
describe('FrenchCloud', () => {
|
||||
test('does not handle non imdb movies', async () => {
|
||||
const streams = await handler.handle(ctx, 'kitsu:123');
|
||||
const streams = await handler.handle(ctx, 'movie', 'kitsu:123');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'tt12345678');
|
||||
const streams = await handler.handle(ctx, 'movie', 'tt12345678');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle imdb the devil\'s bath', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt29141112')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'movie', 'tt29141112')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(2);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class FrenchCloud implements Handler {
|
|||
this.embedExtractors = embedExtractors;
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, id: string) => {
|
||||
readonly handle = async (ctx: Context, _type: string, id: string) => {
|
||||
if (!id.startsWith('tt')) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ const ctx: Context = { ip: '127.0.0.1' };
|
|||
|
||||
describe('KinoKiste', () => {
|
||||
test('does not handle non imdb series', async () => {
|
||||
const streams = await handler.handle(ctx, 'kitsu:123');
|
||||
const streams = await handler.handle(ctx, 'series', 'kitsu:123');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handles non-existent series gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'tt12345678:1:1');
|
||||
const streams = await handler.handle(ctx, 'series', 'tt12345678:1:1');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle imdb black mirror s2e4', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt2085059:2:4')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'series', 'tt2085059:2:4')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(2);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class KinoKiste implements Handler {
|
|||
this.embedExtractors = embedExtractors;
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, id: string) => {
|
||||
readonly handle = async (ctx: Context, _type: string, id: string) => {
|
||||
if (!id.startsWith('tt')) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ const ctx: Context = { ip: '127.0.0.1' };
|
|||
|
||||
describe('MeineCloud', () => {
|
||||
test('does not handle non imdb movies', async () => {
|
||||
const streams = await handler.handle(ctx, 'kitsu:123');
|
||||
const streams = await handler.handle(ctx, 'movie', 'kitsu:123');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'tt12345678');
|
||||
const streams = await handler.handle(ctx, 'movie', 'tt12345678');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle imdb the devil\'s bath', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt29141112')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'movie', 'tt29141112')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(2);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class MeineCloud implements Handler {
|
|||
this.embedExtractors = embedExtractors;
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, id: string) => {
|
||||
readonly handle = async (ctx: Context, _type: string, id: string) => {
|
||||
if (!id.startsWith('tt')) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ const ctx: Context = { ip: '127.0.0.1' };
|
|||
|
||||
describe('MostraGuarda', () => {
|
||||
test('does not handle non imdb movies', async () => {
|
||||
const streams = await handler.handle(ctx, 'kitsu:123');
|
||||
const streams = await handler.handle(ctx, 'movie', 'kitsu:123');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'tt12345678');
|
||||
const streams = await handler.handle(ctx, 'movie', 'tt12345678');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle imdb the devil\'s bath', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt29141112')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'movie', 'tt29141112')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(2);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class MostraGuarda implements Handler {
|
|||
this.embedExtractors = embedExtractors;
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, id: string) => {
|
||||
readonly handle = async (ctx: Context, _type: string, id: string) => {
|
||||
if (!id.startsWith('tt')) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ const ctx: Context = { ip: '127.0.0.1' };
|
|||
|
||||
describe('VerHdLink', () => {
|
||||
test('does not handle non imdb movies', async () => {
|
||||
const streams = await handler.handle(ctx, 'kitsu:123');
|
||||
const streams = await handler.handle(ctx, 'movie', 'kitsu:123');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'tt12345678');
|
||||
const streams = await handler.handle(ctx, 'movie', 'tt12345678');
|
||||
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle titanic', async () => {
|
||||
const streams = (await handler.handle(ctx, 'tt0120338')).filter(stream => stream !== undefined);
|
||||
const streams = (await handler.handle(ctx, 'movie', 'tt0120338')).filter(stream => stream !== undefined);
|
||||
|
||||
expect(streams).toHaveLength(4);
|
||||
expect(streams[0]).toStrictEqual({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class VerHdLink implements Handler {
|
|||
this.embedExtractors = embedExtractors;
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, id: string) => {
|
||||
readonly handle = async (ctx: Context, _type: string, id: string) => {
|
||||
if (!id.startsWith('tt')) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ export interface Handler {
|
|||
|
||||
readonly languages: string[];
|
||||
|
||||
readonly handle: (ctx: Context, id: string) => Promise<(UrlResult | undefined)[]>;
|
||||
readonly handle: (ctx: Context, type: string, id: string) => Promise<(UrlResult | undefined)[]>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export class StreamResolver {
|
|||
}
|
||||
|
||||
try {
|
||||
const handlerUrlResults = await handler.handle(ctx, id);
|
||||
const handlerUrlResults = await handler.handle(ctx, type, id);
|
||||
this.logger.info(`${handler.id} returned ${handlerUrlResults.length} urls`);
|
||||
|
||||
urlResults.push(...(handlerUrlResults.filter(handlerUrlResult => handlerUrlResult !== undefined)));
|
||||
|
|
|
|||
Loading…
Reference in a new issue