diff --git a/src/providers/all.ts b/src/providers/all.ts index 6a7274f..2f7f8a0 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -55,6 +55,7 @@ import { iosmirrorPVScraper } from './sources/iosmirrorpv'; import { ridooMoviesScraper } from './sources/ridomovies'; import { slidemoviesScraper } from './sources/slidemovies'; import { soaperTvScraper } from './sources/soapertv'; +import { streamboxScraper } from './sources/streambox'; import { uiraliveScraper } from './sources/uiralive'; import { vidapiClickScraper } from './sources/vidapiclick'; import { warezcdnScraper } from './sources/warezcdn'; @@ -85,6 +86,7 @@ export function gatherAllSources(): Array { uiraliveScraper, vidapiClickScraper, coitusScraper, + streamboxScraper, ]; } diff --git a/src/providers/sources/streambox.ts b/src/providers/sources/streambox.ts new file mode 100644 index 0000000..4887dcd --- /dev/null +++ b/src/providers/sources/streambox.ts @@ -0,0 +1,85 @@ +/* eslint-disable no-console */ +import { flags } from '@/entrypoint/utils/targets'; +import { SourcererOutput, makeSourcerer } from '@/providers/base'; +import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; +import { NotFoundError } from '@/utils/errors'; + +const streamboxBase = 'https://vidjoy.pro/embed/api/fastfetch'; + +async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise { + const apiRes = await ctx.proxiedFetcher( + ctx.media.type === 'movie' + ? `${streamboxBase}/${ctx.media.tmdbId}?sr=0` + : `${streamboxBase}/${ctx.media.tmdbId}/${ctx.media.season.number}/${ctx.media.episode.number}?sr=0`, + ); + + if (!apiRes) { + throw new NotFoundError('Failed to fetch StreamBox data'); + } + const data = await apiRes; + + const streams: Record = {}; + data.url.forEach((stream: any) => { + streams[stream.resulation] = stream.link; + }); + + const captions = data.tracks.map((track: any) => ({ + id: track.lang, + url: track.url, + language: track.code, + type: 'srt', + })); + + return { + embeds: [], + stream: [ + { + id: 'primary', + captions, + qualities: { + ...(streams['1080'] && { + 1080: { + type: 'mp4', + url: streams['1080'], + }, + }), + ...(streams['720'] && { + 720: { + type: 'mp4', + url: streams['720'], + }, + }), + ...(streams['480'] && { + 480: { + type: 'mp4', + url: streams['480'], + }, + }), + ...(streams['360'] && { + 360: { + type: 'mp4', + url: streams['360'], + }, + }), + }, + type: 'file', + flags: [flags.CORS_ALLOWED], + ...(data.proxy && { + preferredHeaders: { + Referer: 'https://h5.aoneroom.com', + }, + proxyDepth: 1, + }), + }, + ], + }; +} + +export const streamboxScraper = makeSourcerer({ + id: 'streambox', + name: 'StreamBox', + rank: 231, + flags: [flags.CORS_ALLOWED], + scrapeMovie: comboScraper, + scrapeShow: comboScraper, +});