refactor(source): consistently define baseUrl
This commit is contained in:
parent
9f5652eb15
commit
b94c539269
19 changed files with 38 additions and 17 deletions
|
|
@ -13,6 +13,8 @@ export class CineHDPlus implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.es, CountryCode.mx];
|
||||
|
||||
public readonly baseUrl = 'https://cinehdplus.cam';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -50,7 +52,7 @@ export class CineHDPlus implements Source {
|
|||
};
|
||||
|
||||
private fetchSeriesPageUrl = async (ctx: Context, imdbId: ImdbId): Promise<URL | undefined> => {
|
||||
const html = await this.fetcher.text(ctx, new URL(`https://cinehdplus.cam/series/?story=${imdbId.id}&do=search&subaction=search`));
|
||||
const html = await this.fetcher.text(ctx, new URL(`/series/?story=${imdbId.id}&do=search&subaction=search`, this.baseUrl));
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export class Cuevana implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.es, CountryCode.mx];
|
||||
|
||||
public readonly baseUrl = 'https://ww1.cuevana3.is';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -86,7 +88,7 @@ export class Cuevana implements Source {
|
|||
};
|
||||
|
||||
private async fetchPageUrl(ctx: Context, keyword: string): Promise<URL | undefined> {
|
||||
const searchUrl = new URL(`https://ww1.cuevana3.is/search/${encodeURIComponent(keyword)}/`);
|
||||
const searchUrl = new URL(`/search/${encodeURIComponent(keyword)}/`, this.baseUrl);
|
||||
const html = await this.fetcher.text(ctx, searchUrl, { headers: { Referer: searchUrl.origin } });
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export class Eurostreaming implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.it];
|
||||
|
||||
private readonly baseUrl = 'https://eurostreaming.luxe';
|
||||
public readonly baseUrl = 'https://eurostreaming.luxe';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export class Frembed implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.fr];
|
||||
|
||||
private readonly baseUrl = 'https://frembed.top';
|
||||
public readonly baseUrl = 'https://frembed.top';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export class FrenchCloud implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.fr];
|
||||
|
||||
public readonly baseUrl = 'https://frenchcloud.cam';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -22,7 +24,7 @@ export class FrenchCloud implements Source {
|
|||
public async handle(ctx: Context, _type: string, id: Id): Promise<SourceResult[]> {
|
||||
const imdbId = await getImdbId(ctx, this.fetcher, id);
|
||||
|
||||
const pageUrl = new URL(`https://frenchcloud.cam/movie/${imdbId.id}`);
|
||||
const pageUrl = new URL(`/movie/${imdbId.id}`, this.baseUrl);
|
||||
const html = await this.fetcher.text(ctx, pageUrl);
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export class HomeCine implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.es, CountryCode.mx];
|
||||
|
||||
private readonly baseUrl = 'https://www3.homecine.to';
|
||||
public readonly baseUrl = 'https://www3.homecine.to';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export class KinoGer implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.de];
|
||||
|
||||
private readonly baseUrl = 'https://kinoger.com';
|
||||
public readonly baseUrl = 'https://kinoger.com';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export class MegaKino implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.de];
|
||||
|
||||
public readonly baseUrl = 'https://megakino.si';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -42,7 +44,7 @@ export class MegaKino implements Source {
|
|||
};
|
||||
|
||||
private fetchPageUrl = async (ctx: Context, imdbId: ImdbId): Promise<URL | undefined> => {
|
||||
const html = await this.fetcher.text(ctx, new URL(`https://megakino.si/?do=search&subaction=search&story=${imdbId.id}`));
|
||||
const html = await this.fetcher.text(ctx, new URL(`/?do=search&subaction=search&story=${imdbId.id}`, this.baseUrl));
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export class MeineCloud implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.de];
|
||||
|
||||
public readonly baseUrl = 'https://meinecloud.click';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -22,7 +24,7 @@ export class MeineCloud implements Source {
|
|||
public async handle(ctx: Context, _type: string, id: Id): Promise<SourceResult[]> {
|
||||
const imdbId = await getImdbId(ctx, this.fetcher, id);
|
||||
|
||||
const pageUrl = new URL(`https://meinecloud.click/movie/${imdbId.id}`);
|
||||
const pageUrl = new URL(`/movie/${imdbId.id}`, this.baseUrl);
|
||||
const html = await this.fetcher.text(ctx, pageUrl);
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export class MostraGuarda implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.it];
|
||||
|
||||
public readonly baseUrl = 'https://mostraguarda.stream';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -22,7 +24,7 @@ export class MostraGuarda implements Source {
|
|||
public async handle(ctx: Context, _type: string, id: Id): Promise<SourceResult[]> {
|
||||
const imdbId = await getImdbId(ctx, this.fetcher, id);
|
||||
|
||||
const pageUrl = new URL(`https://mostraguarda.stream/movie/${imdbId.id}`);
|
||||
const pageUrl = new URL(`/movie/${imdbId.id}`, this.baseUrl);
|
||||
const html = await this.fetcher.text(ctx, pageUrl);
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export class Movix implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.fr];
|
||||
|
||||
private readonly baseUrl = 'https://api.movix.site';
|
||||
public readonly baseUrl = 'https://api.movix.site';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export class PrimeWire implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.en];
|
||||
|
||||
private readonly baseUrl = 'https://www.primewire.tf';
|
||||
public readonly baseUrl = 'https://www.primewire.tf';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export class Soaper implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.en];
|
||||
|
||||
private readonly baseUrl = 'https://soaper.live';
|
||||
public readonly baseUrl = 'https://soaper.live';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export class StreamKiste implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.de];
|
||||
|
||||
public readonly baseUrl = 'https://streamkiste.taxi';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -45,7 +47,7 @@ export class StreamKiste implements Source {
|
|||
};
|
||||
|
||||
private fetchSeriesPageUrl = async (ctx: Context, imdbId: ImdbId): Promise<URL | undefined> => {
|
||||
const html = await this.fetcher.text(ctx, new URL(`https://streamkiste.taxi/?story=${imdbId.id}&do=search&subaction=search`));
|
||||
const html = await this.fetcher.text(ctx, new URL(`/?story=${imdbId.id}&do=search&subaction=search`, this.baseUrl));
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export class VerHdLink implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.es, CountryCode.mx];
|
||||
|
||||
public readonly baseUrl = 'https://verhdlink.cam';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
public constructor(fetcher: Fetcher) {
|
||||
|
|
@ -22,7 +24,7 @@ export class VerHdLink implements Source {
|
|||
public async handle(ctx: Context, _type: string, id: Id): Promise<SourceResult[]> {
|
||||
const imdbId = await getImdbId(ctx, this.fetcher, id);
|
||||
|
||||
const pageUrl = new URL(`https://verhdlink.cam/movie/${imdbId.id}`);
|
||||
const pageUrl = new URL(`/movie/${imdbId.id}`, this.baseUrl);
|
||||
const html = await this.fetcher.text(ctx, pageUrl);
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export class VidSrc implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.en];
|
||||
|
||||
private readonly baseUrl = 'https://vidsrc.xyz';
|
||||
public readonly baseUrl = 'https://vidsrc.xyz';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export class VixSrc implements Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.multi, CountryCode.it];
|
||||
|
||||
private readonly baseUrl = 'https://vixsrc.to';
|
||||
public readonly baseUrl = 'https://vixsrc.to';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,5 +17,7 @@ export interface Source {
|
|||
|
||||
readonly countryCodes: CountryCode[];
|
||||
|
||||
readonly baseUrl: string;
|
||||
|
||||
handle(ctx: Context, type: ContentType, id: Id): Promise<(SourceResult[])>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ describe('resolve', () => {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.de];
|
||||
|
||||
public readonly baseUrl = 'https://example.com';
|
||||
|
||||
public readonly handle = async (): Promise<SourceResult[]> => {
|
||||
return [{ countryCode: CountryCode.de, url: new URL('https://example.com') }];
|
||||
};
|
||||
|
|
@ -249,6 +251,7 @@ describe('resolve', () => {
|
|||
label: 'MockHandler',
|
||||
contentTypes: ['movie'],
|
||||
countryCodes: [CountryCode.de],
|
||||
baseUrl: 'https://example.com',
|
||||
handle: jest.fn().mockRejectedValue(new NotFoundError()),
|
||||
};
|
||||
const streamResolver = new StreamResolver(logger, new ExtractorRegistry(logger, createExtractors(fetcher)));
|
||||
|
|
|
|||
Loading…
Reference in a new issue