fix(source): switch from imdb to tmdb search for StreamKiste
This commit is contained in:
parent
405a8efad3
commit
076f853a5b
10 changed files with 2168 additions and 974 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { createTestContext } from '../test';
|
||||
import { FetcherMock, ImdbId } from '../utils';
|
||||
import { FetcherMock, TmdbId } from '../utils';
|
||||
import { StreamKiste } from './StreamKiste';
|
||||
|
||||
const ctx = createTestContext({ de: 'on' });
|
||||
|
|
@ -12,12 +12,17 @@ describe('StreamKiste', () => {
|
|||
});
|
||||
|
||||
test('handles non-existent series gracefully', async () => {
|
||||
const streams = await source.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
|
||||
const streams = await source.handle(ctx, 'series', new TmdbId(12345678, 1, 1));
|
||||
expect(streams).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('handle imdb black mirror s2e4', async () => {
|
||||
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 2, 4));
|
||||
test('handle black mirror s2e4', async () => {
|
||||
const streams = await source.handle(ctx, 'series', new TmdbId(42009, 2, 4));
|
||||
expect(streams).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('handle monster: the ed gein story s1e2', async () => {
|
||||
const streams = await source.handle(ctx, 'series', new TmdbId(286801, 1, 2));
|
||||
expect(streams).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { ContentType } from 'stremio-addon-sdk';
|
||||
import { Context, CountryCode } from '../types';
|
||||
import { Fetcher, getImdbId, Id, ImdbId } from '../utils';
|
||||
import { Fetcher, getTmdbId, Id, TmdbId } from '../utils';
|
||||
import { Source, SourceResult } from './Source';
|
||||
|
||||
export class StreamKiste extends Source {
|
||||
|
|
@ -24,9 +24,9 @@ export class StreamKiste extends Source {
|
|||
}
|
||||
|
||||
public async handleInternal(ctx: Context, _type: string, id: Id): Promise<SourceResult[]> {
|
||||
const imdbId = await getImdbId(ctx, this.fetcher, id);
|
||||
const tmdbId = await getTmdbId(ctx, this.fetcher, id);
|
||||
|
||||
const seriesPageUrl = await this.fetchSeriesPageUrl(ctx, imdbId);
|
||||
const seriesPageUrl = await this.fetchSeriesPageUrl(ctx, tmdbId);
|
||||
if (!seriesPageUrl) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -35,10 +35,10 @@ export class StreamKiste extends Source {
|
|||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const title = `${($('meta[property="og:title"]').attr('content') as string).trim()} ${imdbId.season}x${imdbId.episode}`;
|
||||
const title = `${($('meta[property="og:title"]').attr('content') as string).trim()} ${tmdbId.season}x${tmdbId.episode}`;
|
||||
|
||||
return Promise.all(
|
||||
$(`[data-num="${imdbId.season}x${imdbId.episode}"]`)
|
||||
$(`[data-num="${tmdbId.season}x${tmdbId.episode}"]`)
|
||||
.siblings('.mirrors')
|
||||
.children('[data-link]')
|
||||
.map((_i, el) => new URL(($(el).attr('data-link') as string).replace(/^(https:)?\/\//, 'https://')))
|
||||
|
|
@ -48,15 +48,13 @@ export class StreamKiste extends Source {
|
|||
);
|
||||
};
|
||||
|
||||
private fetchSeriesPageUrl = async (ctx: Context, imdbId: ImdbId): Promise<URL | undefined> => {
|
||||
const html = await this.fetcher.text(ctx, new URL(`/?story=${imdbId.id}&do=search&subaction=search`, this.baseUrl));
|
||||
private fetchSeriesPageUrl = async (ctx: Context, tmdbId: TmdbId): Promise<URL | undefined> => {
|
||||
const html = await this.fetcher.text(ctx, new URL(`/?story=${tmdbId.id}&do=search&subaction=search`, this.baseUrl));
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const url = $('.res_item a[href]:first')
|
||||
.map((_i, el) => $(el).attr('href'))
|
||||
return $('.res_item a[href]:first')
|
||||
.map((_i, el) => new URL($(el).attr('href') as string))
|
||||
.get(0);
|
||||
|
||||
return url !== undefined ? new URL(url) : url;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
418
src/source/__fixtures__/StreamKiste/https:streamkiste.taxistory12345678anddosearchandsubactionsearch
generated
Normal file
418
src/source/__fixtures__/StreamKiste/https:streamkiste.taxistory12345678anddosearchandsubactionsearch
generated
Normal file
File diff suppressed because one or more lines are too long
455
src/source/__fixtures__/StreamKiste/https:streamkiste.taxistory286801anddosearchandsubactionsearch
generated
Normal file
455
src/source/__fixtures__/StreamKiste/https:streamkiste.taxistory286801anddosearchandsubactionsearch
generated
Normal file
File diff suppressed because one or more lines are too long
455
src/source/__fixtures__/StreamKiste/https:streamkiste.taxistory42009anddosearchandsubactionsearch
generated
Normal file
455
src/source/__fixtures__/StreamKiste/https:streamkiste.taxistory42009anddosearchandsubactionsearch
generated
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
|||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`StreamKiste handle imdb black mirror s2e4 1`] = `
|
||||
exports[`StreamKiste handle black mirror s2e4 1`] = `
|
||||
[
|
||||
{
|
||||
"meta": {
|
||||
|
|
@ -24,3 +24,18 @@ exports[`StreamKiste handle imdb black mirror s2e4 1`] = `
|
|||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`StreamKiste handle monster: the ed gein story s1e2 1`] = `
|
||||
[
|
||||
{
|
||||
"meta": {
|
||||
"countryCodes": [
|
||||
"de",
|
||||
],
|
||||
"referer": "https://streamkiste.taxi/movie/40087-monster-die-geschichte-von-ed-gein-stream-kostenlos.html",
|
||||
"title": "Monster: Die Geschichte von Ed Gein 1x2",
|
||||
},
|
||||
"url": "https://supervideo.cc/embed-lfwd3ytzsyry.html",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
|
|
|||
Loading…
Reference in a new issue