Add redstar source

This commit is contained in:
TPN 2024-08-12 15:58:44 +00:00
parent 2627406b77
commit ac0ceff7d8
2 changed files with 44 additions and 0 deletions

View file

@ -24,6 +24,7 @@ import { insertunitScraper } from '@/providers/sources/insertunit';
import { kissAsianScraper } from '@/providers/sources/kissasian/index';
import { lookmovieScraper } from '@/providers/sources/lookmovie';
import { nsbxScraper } from '@/providers/sources/nsbx';
import { redStarScraper } from '@/providers/sources/redstar';
import { remotestreamScraper } from '@/providers/sources/remotestream';
import { showboxScraper } from '@/providers/sources/showbox/index';
import { tugaflixScraper } from '@/providers/sources/tugaflix';
@ -99,6 +100,7 @@ export function gatherAllSources(): Array<Sourcerer> {
ee3Scraper,
whvxScraper,
fsharetvScraper,
redStarScraper,
];
}

View file

@ -0,0 +1,42 @@
import { flags } from '@/entrypoint/utils/targets';
import { SourcererOutput, makeSourcerer } from '@/providers/base';
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
import { NotFoundError } from '@/utils/errors';
const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> => {
try {
const res = await ctx.fetcher.full(`https://red-star.gobly.ru/scrape/showbox`, {
query: {
type: ctx.media.type,
title: ctx.media.title,
releaseYear: ctx.media.releaseYear.toString(),
tmdbId: ctx.media.tmdbId,
imdbId: ctx.media.imdbId ?? '',
...(ctx.media.type === 'show' && {
episodeNumber: ctx.media.episode.number.toString(),
episodeTmdbId: ctx.media.episode.tmdbId,
seasonNumber: ctx.media.season.number.toString(),
seasonTmdbId: ctx.media.season.tmdbId,
}),
},
});
if (res.statusCode === 200 && res.body.stream?.length)
return { stream: res.body.stream, embeds: [] } as SourcererOutput;
if (res.statusCode === 404) throw new NotFoundError('No watchable item found');
throw new Error(res.body.message ?? 'An error has occurred!');
} catch (e: any) {
if (e instanceof NotFoundError) throw new NotFoundError(e.message);
throw new Error(e.message ?? 'An error has occurred!');
}
};
export const redStarScraper = makeSourcerer({
id: 'redstar',
name: 'redStar',
rank: 131,
flags: [flags.CORS_ALLOWED],
scrapeMovie: universalScraper,
scrapeShow: universalScraper,
});