mirror of
https://github.com/sussy-code/providers.git
synced 2026-03-11 17:55:37 +00:00
Add whvs source
This commit is contained in:
parent
3001ad69ab
commit
c5727e7653
3 changed files with 106 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ import { upcloudScraper } from '@/providers/embeds/upcloud';
|
|||
import { upstreamScraper } from '@/providers/embeds/upstream';
|
||||
import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
|
||||
import { vTubeScraper } from '@/providers/embeds/vtube';
|
||||
import { astraScraper, novaScraper } from '@/providers/embeds/whvx';
|
||||
import { autoembedScraper } from '@/providers/sources/autoembed';
|
||||
import { flixhqScraper } from '@/providers/sources/flixhq/index';
|
||||
import { goMoviesScraper } from '@/providers/sources/gomovies/index';
|
||||
|
|
@ -23,6 +24,7 @@ import { remotestreamScraper } from '@/providers/sources/remotestream';
|
|||
import { showboxScraper } from '@/providers/sources/showbox/index';
|
||||
import { tugaflixScraper } from '@/providers/sources/tugaflix';
|
||||
import { vidsrcScraper } from '@/providers/sources/vidsrc/index';
|
||||
import { whvxScraper } from '@/providers/sources/whvx';
|
||||
import { zoechipScraper } from '@/providers/sources/zoechip';
|
||||
|
||||
import {
|
||||
|
|
@ -88,6 +90,7 @@ export function gatherAllSources(): Array<Sourcerer> {
|
|||
soaperTvScraper,
|
||||
autoembedScraper,
|
||||
tugaflixScraper,
|
||||
whvxScraper,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -131,5 +134,7 @@ export function gatherAllEmbeds(): Array<Embed> {
|
|||
autoembedBengaliScraper,
|
||||
autoembedTamilScraper,
|
||||
autoembedTeluguScraper,
|
||||
novaScraper,
|
||||
astraScraper,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
56
src/providers/embeds/whvx.ts
Normal file
56
src/providers/embeds/whvx.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { EmbedOutput, makeEmbed } from '@/providers/base';
|
||||
import { NotFoundError } from '@/utils/errors';
|
||||
|
||||
import { baseUrl } from '../sources/whvx';
|
||||
|
||||
const providers = [
|
||||
{
|
||||
id: 'nova',
|
||||
name: 'VidBinge Nova',
|
||||
rank: 697,
|
||||
},
|
||||
{
|
||||
id: 'astra',
|
||||
name: 'VidBinge Astra',
|
||||
rank: 696,
|
||||
},
|
||||
];
|
||||
|
||||
function embed(provider: { id: string; name: string; rank: number }) {
|
||||
return makeEmbed({
|
||||
id: provider.id,
|
||||
name: provider.name,
|
||||
rank: provider.rank,
|
||||
disabled: false,
|
||||
async scrape(ctx) {
|
||||
const query = ctx.url;
|
||||
|
||||
const search = await ctx.fetcher.full('/search', {
|
||||
query: {
|
||||
query,
|
||||
provider: provider.id,
|
||||
},
|
||||
baseUrl,
|
||||
});
|
||||
|
||||
if (search.statusCode === 429) throw new Error('Rate limited');
|
||||
if (search.statusCode !== 200) throw new NotFoundError('Failed to search');
|
||||
|
||||
ctx.progress(50);
|
||||
|
||||
const result = await ctx.fetcher('/source', {
|
||||
query: {
|
||||
resourceId: search.body.url,
|
||||
provider: provider.id,
|
||||
},
|
||||
baseUrl,
|
||||
});
|
||||
|
||||
ctx.progress(100);
|
||||
|
||||
return result as EmbedOutput;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const [novaScraper, astraScraper] = providers.map(embed);
|
||||
45
src/providers/sources/whvx.ts
Normal file
45
src/providers/sources/whvx.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { flags } from '@/entrypoint/utils/targets';
|
||||
import { SourcererOutput, makeSourcerer } from '@/providers/base';
|
||||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||
import { NotFoundError } from '@/utils/errors';
|
||||
|
||||
export const baseUrl = 'https://api.whvx.net';
|
||||
|
||||
async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> {
|
||||
const query = {
|
||||
title: ctx.media.title,
|
||||
releaseYear: ctx.media.releaseYear,
|
||||
tmdbId: ctx.media.tmdbId,
|
||||
imdbId: ctx.media.imdbId,
|
||||
type: ctx.media.type,
|
||||
...(ctx.media.type === 'show' && {
|
||||
season: ctx.media.season.number.toString(),
|
||||
episode: ctx.media.episode.number.toString(),
|
||||
}),
|
||||
};
|
||||
|
||||
const res: { providers: string[] } = await ctx.fetcher('/status', { baseUrl });
|
||||
|
||||
if (res.providers?.length === 0) throw new NotFoundError('No providers available');
|
||||
|
||||
const embeds = res.providers.map((provider: string) => {
|
||||
return {
|
||||
embedId: provider,
|
||||
url: JSON.stringify(query),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
embeds,
|
||||
};
|
||||
}
|
||||
|
||||
export const whvxScraper = makeSourcerer({
|
||||
id: 'whvx',
|
||||
name: 'WHVX',
|
||||
rank: 149,
|
||||
flags: [flags.CORS_ALLOWED],
|
||||
disabled: false,
|
||||
scrapeMovie: comboScraper,
|
||||
scrapeShow: comboScraper,
|
||||
});
|
||||
Loading…
Reference in a new issue