fix(source): switch from imdb to tmdb search for CineHDPlus
This commit is contained in:
parent
076f853a5b
commit
c88b3798f0
8 changed files with 525 additions and 493 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { createTestContext } from '../test';
|
||||
import { FetcherMock, ImdbId } from '../utils';
|
||||
import { FetcherMock, TmdbId } from '../utils';
|
||||
import { CineHDPlus } from './CineHDPlus';
|
||||
|
||||
const ctx = createTestContext({ es: 'on', mx: 'on' });
|
||||
|
|
@ -12,25 +12,25 @@ describe('CineHDPlus', () => {
|
|||
});
|
||||
|
||||
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 s2e3 (mx)', async () => {
|
||||
const streams = await source.handle(ctx, 'series', new ImdbId('tt2085059', 2, 3));
|
||||
const streams = await source.handle(ctx, 'series', new TmdbId(42009, 2, 3));
|
||||
expect(streams).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('handle imdb babylon 5 s2e3 (es)', async () => {
|
||||
const streams = await source.handle(ctx, 'series', new ImdbId('tt0105946', 2, 3));
|
||||
const streams = await source.handle(ctx, 'series', new TmdbId(3137, 2, 3));
|
||||
expect(streams).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('does not return mx results for es and vice-versa', async () => {
|
||||
const streamsEs = await source.handle({ ...ctx, ...{ config: { es: 'on' } } }, 'series', new ImdbId('tt2085059', 2, 3));
|
||||
const streamsEs = await source.handle({ ...ctx, ...{ config: { es: 'on' } } }, 'series', new TmdbId(42009, 2, 3));
|
||||
expect(streamsEs).toHaveLength(0);
|
||||
|
||||
const streamsMx = await source.handle({ ...ctx, ...{ config: { mx: 'on' } } }, 'series', new ImdbId('tt0105946', 2, 3));
|
||||
const streamsMx = await source.handle({ ...ctx, ...{ config: { mx: 'on' } } }, 'series', new TmdbId(3137, 2, 3));
|
||||
expect(streamsMx).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 CineHDPlus extends Source {
|
||||
|
|
@ -13,7 +13,7 @@ export class CineHDPlus extends Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.es, CountryCode.mx];
|
||||
|
||||
public readonly baseUrl = 'https://cinehdplus.cam';
|
||||
public readonly baseUrl = 'https://cinehdplus.gratis';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
@ -24,9 +24,9 @@ export class CineHDPlus 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 [];
|
||||
}
|
||||
|
|
@ -37,10 +37,10 @@ export class CineHDPlus extends Source {
|
|||
|
||||
const countryCodes = [($('.details__langs').html() as string).includes('Latino') ? CountryCode.mx : CountryCode.es];
|
||||
|
||||
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://')))
|
||||
|
|
@ -50,8 +50,8 @@ export class CineHDPlus extends Source {
|
|||
);
|
||||
};
|
||||
|
||||
private fetchSeriesPageUrl = async (ctx: Context, imdbId: ImdbId): Promise<URL | undefined> => {
|
||||
const html = await this.fetcher.text(ctx, new URL(`/series/?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(`/series/?story=${tmdbId.id}&do=search&subaction=search`, this.baseUrl));
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
|
|
|
|||
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -7,7 +7,7 @@ exports[`CineHDPlus handle imdb babylon 5 s2e3 (es) 1`] = `
|
|||
"countryCodes": [
|
||||
"es",
|
||||
],
|
||||
"referer": "https://cinehdplus.cam/peliculas/19678-babylon-5-ver-online-hd.html",
|
||||
"referer": "https://cinehdplus.gratis/peliculas/19678-babylon-5-ver-online-hd.html",
|
||||
"title": "Babylon 5 2x3",
|
||||
},
|
||||
"url": "https://supervideo.tv/embed-1p0m1fi9mok8.html",
|
||||
|
|
@ -17,7 +17,7 @@ exports[`CineHDPlus handle imdb babylon 5 s2e3 (es) 1`] = `
|
|||
"countryCodes": [
|
||||
"es",
|
||||
],
|
||||
"referer": "https://cinehdplus.cam/peliculas/19678-babylon-5-ver-online-hd.html",
|
||||
"referer": "https://cinehdplus.gratis/peliculas/19678-babylon-5-ver-online-hd.html",
|
||||
"title": "Babylon 5 2x3",
|
||||
},
|
||||
"url": "https://dropload.io/embed-957hny8mzrvh.html",
|
||||
|
|
@ -32,7 +32,7 @@ exports[`CineHDPlus handle imdb black mirror s2e3 (mx) 1`] = `
|
|||
"countryCodes": [
|
||||
"mx",
|
||||
],
|
||||
"referer": "https://cinehdplus.cam/peliculas/9582-black-mirror-ver-online-hd.html",
|
||||
"referer": "https://cinehdplus.gratis/peliculas/9582-black-mirror-ver-online-hd.html",
|
||||
"title": "Black Mirror 2x3",
|
||||
},
|
||||
"url": "https://supervideo.tv/embed-avmgppo37sx1.html",
|
||||
|
|
@ -42,7 +42,7 @@ exports[`CineHDPlus handle imdb black mirror s2e3 (mx) 1`] = `
|
|||
"countryCodes": [
|
||||
"mx",
|
||||
],
|
||||
"referer": "https://cinehdplus.cam/peliculas/9582-black-mirror-ver-online-hd.html",
|
||||
"referer": "https://cinehdplus.gratis/peliculas/9582-black-mirror-ver-online-hd.html",
|
||||
"title": "Black Mirror 2x3",
|
||||
},
|
||||
"url": "https://dropload.io/embed-t058ulwwkwn6.html",
|
||||
|
|
|
|||
Loading…
Reference in a new issue