From 6737c7a68fbba73664f66409a4447e91b7eee709 Mon Sep 17 00:00:00 2001 From: TPN Date: Sun, 30 Jun 2024 13:09:40 +0530 Subject: [PATCH 01/13] Add temporary option `proxyStreams` in ProviderMakerOptions --- src/entrypoint/controls.ts | 8 ++++++++ src/entrypoint/declare.ts | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/entrypoint/controls.ts b/src/entrypoint/controls.ts index 5ff400b..cfcd627 100644 --- a/src/entrypoint/controls.ts +++ b/src/entrypoint/controls.ts @@ -14,6 +14,7 @@ export interface ProviderControlsInput { features: FeatureMap; sources: Sourcerer[]; embeds: Embed[]; + proxyStreams?: boolean; // temporary } export interface RunnerOptions { @@ -30,6 +31,8 @@ export interface RunnerOptions { // the media you want to see sources from media: ScrapeMedia; + + proxyStreams?: boolean; // temporary } export interface SourceRunnerOptions { @@ -41,6 +44,8 @@ export interface SourceRunnerOptions { // id of the source scraper you want to scrape from id: string; + + proxyStreams?: boolean; // temporary } export interface EmbedRunnerOptions { @@ -52,6 +57,8 @@ export interface EmbedRunnerOptions { // id of the embed scraper you want to scrape from id: string; + + proxyStreams?: boolean; // temporary } export interface ProviderControls { @@ -85,6 +92,7 @@ export function makeControls(ops: ProviderControlsInput): ProviderControls { features: ops.features, fetcher: makeFetcher(ops.fetcher), proxiedFetcher: makeFetcher(ops.proxiedFetcher ?? ops.fetcher), + proxyStreams: ops.proxyStreams, }; return { diff --git a/src/entrypoint/declare.ts b/src/entrypoint/declare.ts index 152ee87..53c69a9 100644 --- a/src/entrypoint/declare.ts +++ b/src/entrypoint/declare.ts @@ -18,6 +18,9 @@ export interface ProviderMakerOptions { // Set this to true, if the requests will have the same IP as // the device that the stream will be played on consistentIpForRequests?: boolean; + + // This is temporary + proxyStreams?: boolean; } export function makeProviders(ops: ProviderMakerOptions) { @@ -33,5 +36,6 @@ export function makeProviders(ops: ProviderMakerOptions) { features, fetcher: ops.fetcher, proxiedFetcher: ops.proxiedFetcher, + proxyStreams: ops.proxyStreams, }); } From 53534cb5ffadae4158c5d9d9e0f5bb8ba61a1f22 Mon Sep 17 00:00:00 2001 From: TPN Date: Sun, 30 Jun 2024 13:11:17 +0530 Subject: [PATCH 02/13] Change freatures if proxyStreams is set --- src/entrypoint/declare.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entrypoint/declare.ts b/src/entrypoint/declare.ts index 53c69a9..fab7bad 100644 --- a/src/entrypoint/declare.ts +++ b/src/entrypoint/declare.ts @@ -24,7 +24,7 @@ export interface ProviderMakerOptions { } export function makeProviders(ops: ProviderMakerOptions) { - const features = getTargetFeatures(ops.target, ops.consistentIpForRequests ?? false); + const features = getTargetFeatures(ops.proxyStreams ? 'any' : ops.target, ops.consistentIpForRequests ?? false); const list = getProviders(features, { embeds: getBuiltinEmbeds(), sources: getBuiltinSources(), From 0f95ed0b201fb62e53a0a12d60168a281c3ff76c Mon Sep 17 00:00:00 2001 From: TPN Date: Sun, 30 Jun 2024 16:28:02 +0530 Subject: [PATCH 03/13] Support proxy on runners --- src/entrypoint/controls.ts | 6 ------ src/runners/individualRunner.ts | 11 +++++++++++ src/runners/runner.ts | 9 +++++++++ src/utils/proxy.ts | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/utils/proxy.ts diff --git a/src/entrypoint/controls.ts b/src/entrypoint/controls.ts index cfcd627..1441643 100644 --- a/src/entrypoint/controls.ts +++ b/src/entrypoint/controls.ts @@ -31,8 +31,6 @@ export interface RunnerOptions { // the media you want to see sources from media: ScrapeMedia; - - proxyStreams?: boolean; // temporary } export interface SourceRunnerOptions { @@ -44,8 +42,6 @@ export interface SourceRunnerOptions { // id of the source scraper you want to scrape from id: string; - - proxyStreams?: boolean; // temporary } export interface EmbedRunnerOptions { @@ -57,8 +53,6 @@ export interface EmbedRunnerOptions { // id of the embed scraper you want to scrape from id: string; - - proxyStreams?: boolean; // temporary } export interface ProviderControls { diff --git a/src/runners/individualRunner.ts b/src/runners/individualRunner.ts index da7fca9..0d9e29f 100644 --- a/src/runners/individualRunner.ts +++ b/src/runners/individualRunner.ts @@ -7,6 +7,7 @@ import { ProviderList } from '@/providers/get'; import { ScrapeContext } from '@/utils/context'; import { NotFoundError } from '@/utils/errors'; import { addOpenSubtitlesCaptions } from '@/utils/opensubtitles'; +import { requiresProxy, setupProxy } from '@/utils/proxy'; import { isValidStream, validatePlayableStreams } from '@/utils/valid'; export type IndividualSourceRunnerOptions = { @@ -16,6 +17,7 @@ export type IndividualSourceRunnerOptions = { media: ScrapeMedia; id: string; events?: IndividualScraperEvents; + proxyStreams?: boolean; // temporary }; export async function scrapeInvidualSource( @@ -56,6 +58,10 @@ export async function scrapeInvidualSource( output.stream = output.stream .filter((stream) => isValidStream(stream)) .filter((stream) => flagsAllowedInFeatures(ops.features, stream.flags)); + + output.stream = output.stream.map((stream) => + requiresProxy(stream) && ops.proxyStreams ? setupProxy(stream) : stream, + ); } if (!output) throw new Error('output is null'); @@ -107,6 +113,7 @@ export type IndividualEmbedRunnerOptions = { url: string; id: string; events?: IndividualScraperEvents; + proxyStreams?: boolean; // temporary }; export async function scrapeIndividualEmbed( @@ -138,6 +145,10 @@ export async function scrapeIndividualEmbed( .filter((stream) => flagsAllowedInFeatures(ops.features, stream.flags)); if (output.stream.length === 0) throw new NotFoundError('No streams found'); + output.stream = output.stream.map((stream) => + requiresProxy(stream) && ops.proxyStreams ? setupProxy(stream) : stream, + ); + const playableStreams = await validatePlayableStreams(output.stream, ops, embedScraper.id); if (playableStreams.length === 0) throw new NotFoundError('No playable streams found'); diff --git a/src/runners/runner.ts b/src/runners/runner.ts index 9e79b30..fca9410 100644 --- a/src/runners/runner.ts +++ b/src/runners/runner.ts @@ -9,6 +9,7 @@ import { ScrapeContext } from '@/utils/context'; import { NotFoundError } from '@/utils/errors'; import { reorderOnIdList } from '@/utils/list'; import { addOpenSubtitlesCaptions } from '@/utils/opensubtitles'; +import { requiresProxy, setupProxy } from '@/utils/proxy'; import { isValidStream, validatePlayableStream } from '@/utils/valid'; export type RunOutput = { @@ -36,6 +37,7 @@ export type ProviderRunnerOptions = { embedOrder?: string[]; events?: FullScraperEvents; media: ScrapeMedia; + proxyStreams?: boolean; // temporary }; export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOptions): Promise { @@ -85,6 +87,10 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt output.stream = (output.stream ?? []) .filter(isValidStream) .filter((stream) => flagsAllowedInFeatures(ops.features, stream.flags)); + + output.stream = output.stream.map((stream) => + requiresProxy(stream) && ops.proxyStreams ? setupProxy(stream) : stream, + ); } if (!output || (!output.stream?.length && !output.embeds.length)) { throw new NotFoundError('No streams found'); @@ -161,6 +167,9 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt embedOutput.stream = embedOutput.stream .filter(isValidStream) .filter((stream) => flagsAllowedInFeatures(ops.features, stream.flags)); + embedOutput.stream = embedOutput.stream.map((stream) => + requiresProxy(stream) && ops.proxyStreams ? setupProxy(stream) : stream, + ); if (embedOutput.stream.length === 0) { throw new NotFoundError('No streams found'); } diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts new file mode 100644 index 0000000..30e0291 --- /dev/null +++ b/src/utils/proxy.ts @@ -0,0 +1,16 @@ +import { flags } from '@/entrypoint/utils/targets'; +import { Stream } from '@/providers/streams'; + +export function requiresProxy(stream: Stream): boolean { + if (!stream.flags.includes('cors-allowed') && !!(stream.headers && Object.keys(stream.headers).length > 0)) + return true; + return false; +} + +export function setupProxy(stream: Stream): Stream { + // todo + + // stream.headers = {}; + stream.flags = [flags.CORS_ALLOWED]; + return stream; +} From 78dbbf7520bfe4609cd56e46bc8c5e765a174901 Mon Sep 17 00:00:00 2001 From: TPN Date: Mon, 1 Jul 2024 07:31:27 +0100 Subject: [PATCH 04/13] Complete setup proxy function --- src/utils/proxy.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts index 30e0291..2defa8f 100644 --- a/src/utils/proxy.ts +++ b/src/utils/proxy.ts @@ -8,9 +8,20 @@ export function requiresProxy(stream: Stream): boolean { } export function setupProxy(stream: Stream): Stream { - // todo + const headers = + stream.headers && Object.keys(stream.headers).length > 0 + ? encodeURIComponent(JSON.stringify(stream.headers)) + : null; - // stream.headers = {}; + if (stream.type === 'hls') + stream.playlist = `https://busty.prawnhub.ru/proxy/${encodeURIComponent(stream.playlist)}/${headers}`; + + if (stream.type === 'file') + Object.entries(stream.qualities).forEach((entry) => { + entry[1].url = `https://mp4proxy.nsbxru.workers.dev/proxy/${encodeURIComponent(entry[1].url)}/${headers}`; + }); + + stream.headers = {}; stream.flags = [flags.CORS_ALLOWED]; return stream; } From 97f34011fc0f97727bfa4709cf0d9077967472e2 Mon Sep 17 00:00:00 2001 From: TPN Date: Mon, 1 Jul 2024 13:25:36 +0100 Subject: [PATCH 05/13] Update hls proxy --- src/utils/proxy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts index 2defa8f..b97aa53 100644 --- a/src/utils/proxy.ts +++ b/src/utils/proxy.ts @@ -14,7 +14,7 @@ export function setupProxy(stream: Stream): Stream { : null; if (stream.type === 'hls') - stream.playlist = `https://busty.prawnhub.ru/proxy/${encodeURIComponent(stream.playlist)}/${headers}`; + stream.playlist = `https://swallow.prawnhub.ru/${encodeURIComponent(stream.playlist)}/${headers}`; if (stream.type === 'file') Object.entries(stream.qualities).forEach((entry) => { From d8bbe3bb5e9e7e0ef7e4fae2b538b4a076503ecb Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 07:58:15 +0100 Subject: [PATCH 06/13] Add new `proxy-blocked` flag and update proxy --- src/entrypoint/declare.ts | 6 +++++- src/entrypoint/utils/targets.ts | 11 ++++++++++- src/utils/proxy.ts | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/entrypoint/declare.ts b/src/entrypoint/declare.ts index fab7bad..ad1098b 100644 --- a/src/entrypoint/declare.ts +++ b/src/entrypoint/declare.ts @@ -24,7 +24,11 @@ export interface ProviderMakerOptions { } export function makeProviders(ops: ProviderMakerOptions) { - const features = getTargetFeatures(ops.proxyStreams ? 'any' : ops.target, ops.consistentIpForRequests ?? false); + const features = getTargetFeatures( + ops.proxyStreams ? 'any' : ops.target, + ops.consistentIpForRequests ?? false, + ops.proxyStreams ?? false, + ); const list = getProviders(features, { embeds: getBuiltinEmbeds(), sources: getBuiltinSources(), diff --git a/src/entrypoint/utils/targets.ts b/src/entrypoint/utils/targets.ts index 80988a4..94b724a 100644 --- a/src/entrypoint/utils/targets.ts +++ b/src/entrypoint/utils/targets.ts @@ -9,6 +9,10 @@ export const flags = { // The source/embed is blocking cloudflare ip's // This flag is not compatible with a proxy hosted on cloudflare CF_BLOCKED: 'cf-blocked', + + // Streams and sources with this flag wont be proxied + // And will be exclusive to the extension + PROXY_BLOCKED: 'proxy-blocked', } as const; export type Flags = (typeof flags)[keyof typeof flags]; @@ -53,9 +57,14 @@ export const targetToFeatures: Record = { }, }; -export function getTargetFeatures(target: Targets, consistentIpForRequests: boolean): FeatureMap { +export function getTargetFeatures( + target: Targets, + consistentIpForRequests: boolean, + proxyStreams: boolean, +): FeatureMap { const features = targetToFeatures[target]; if (!consistentIpForRequests) features.disallowed.push(flags.IP_LOCKED); + if (proxyStreams) features.disallowed.push(flags.PROXY_BLOCKED); return features; } diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts index b97aa53..e57f74a 100644 --- a/src/utils/proxy.ts +++ b/src/utils/proxy.ts @@ -14,11 +14,11 @@ export function setupProxy(stream: Stream): Stream { : null; if (stream.type === 'hls') - stream.playlist = `https://swallow.prawnhub.ru/${encodeURIComponent(stream.playlist)}/${headers}`; + stream.playlist = `https://proxy.nsbx.ru/hls/${encodeURIComponent(stream.playlist)}/${headers}`; if (stream.type === 'file') Object.entries(stream.qualities).forEach((entry) => { - entry[1].url = `https://mp4proxy.nsbxru.workers.dev/proxy/${encodeURIComponent(entry[1].url)}/${headers}`; + entry[1].url = `https://proxy.nsbx.ru/mp4/${encodeURIComponent(entry[1].url)}/${headers}`; }); stream.headers = {}; From 053ca3fe5a6b1133321c126d95eb999d5707e893 Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 08:26:08 +0100 Subject: [PATCH 07/13] Fix --- src/entrypoint/declare.ts | 2 +- src/entrypoint/utils/targets.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entrypoint/declare.ts b/src/entrypoint/declare.ts index ad1098b..55f08e3 100644 --- a/src/entrypoint/declare.ts +++ b/src/entrypoint/declare.ts @@ -27,7 +27,7 @@ export function makeProviders(ops: ProviderMakerOptions) { const features = getTargetFeatures( ops.proxyStreams ? 'any' : ops.target, ops.consistentIpForRequests ?? false, - ops.proxyStreams ?? false, + ops.proxyStreams, ); const list = getProviders(features, { embeds: getBuiltinEmbeds(), diff --git a/src/entrypoint/utils/targets.ts b/src/entrypoint/utils/targets.ts index 94b724a..b3e4200 100644 --- a/src/entrypoint/utils/targets.ts +++ b/src/entrypoint/utils/targets.ts @@ -60,7 +60,7 @@ export const targetToFeatures: Record = { export function getTargetFeatures( target: Targets, consistentIpForRequests: boolean, - proxyStreams: boolean, + proxyStreams?: boolean, ): FeatureMap { const features = targetToFeatures[target]; if (!consistentIpForRequests) features.disallowed.push(flags.IP_LOCKED); From 5c95f64c69a630967ee2a02d8a06795561ab9ae5 Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 09:05:50 +0100 Subject: [PATCH 08/13] Update Flags for vidsrcto --- src/providers/embeds/filemoon/index.ts | 4 +++- src/providers/embeds/filemoon/mp4.ts | 3 ++- src/providers/embeds/vidplay/index.ts | 3 ++- src/providers/sources/vidsrcto/index.ts | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/providers/embeds/filemoon/index.ts b/src/providers/embeds/filemoon/index.ts index be1d9d3..8ed7646 100644 --- a/src/providers/embeds/filemoon/index.ts +++ b/src/providers/embeds/filemoon/index.ts @@ -1,6 +1,8 @@ import { load } from 'cheerio'; import { unpack } from 'unpacker'; +import { flags } from '@/entrypoint/utils/targets'; + import { SubtitleResult } from './types'; import { makeEmbed } from '../../base'; import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '../../captions'; @@ -51,7 +53,7 @@ export const fileMoonScraper = makeEmbed({ id: 'primary', type: 'hls', playlist: file[1], - flags: [], + flags: [flags.IP_LOCKED], captions, }, ], diff --git a/src/providers/embeds/filemoon/mp4.ts b/src/providers/embeds/filemoon/mp4.ts index 181453b..35580c6 100644 --- a/src/providers/embeds/filemoon/mp4.ts +++ b/src/providers/embeds/filemoon/mp4.ts @@ -1,3 +1,4 @@ +import { flags } from '@/entrypoint/utils/targets'; import { NotFoundError } from '@/utils/errors'; import { makeEmbed } from '../../base'; @@ -28,7 +29,7 @@ export const fileMoonMp4Scraper = makeEmbed({ url, }, }, - flags: [], + flags: [flags.IP_LOCKED], captions: result.stream[0].captions, }, ], diff --git a/src/providers/embeds/vidplay/index.ts b/src/providers/embeds/vidplay/index.ts index 781909c..4084e82 100644 --- a/src/providers/embeds/vidplay/index.ts +++ b/src/providers/embeds/vidplay/index.ts @@ -1,3 +1,4 @@ +import { flags } from '@/entrypoint/utils/targets'; import { makeEmbed } from '@/providers/base'; import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions'; @@ -53,7 +54,7 @@ export const vidplayScraper = makeEmbed({ id: 'primary', type: 'hls', playlist: source, - flags: [], + flags: [flags.PROXY_BLOCKED], headers: { Referer: url.origin, Origin: url.origin, diff --git a/src/providers/sources/vidsrcto/index.ts b/src/providers/sources/vidsrcto/index.ts index 3bb7b92..c87b54f 100644 --- a/src/providers/sources/vidsrcto/index.ts +++ b/src/providers/sources/vidsrcto/index.ts @@ -1,5 +1,6 @@ import { load } from 'cheerio'; +import { flags } from '@/entrypoint/utils/targets'; import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base'; import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; @@ -83,6 +84,6 @@ export const vidSrcToScraper = makeSourcerer({ name: 'VidSrcTo', scrapeMovie: universalScraper, scrapeShow: universalScraper, - flags: [], + flags: [flags.PROXY_BLOCKED], rank: 130, }); From c8b3a151ff5d6a367ef9b12203728f88495df19c Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 09:07:24 +0100 Subject: [PATCH 09/13] Disable smashystream and autoembed --- src/providers/sources/autoembed.ts | 1 + src/providers/sources/smashystream/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/providers/sources/autoembed.ts b/src/providers/sources/autoembed.ts index 1aa4796..e4d9a2e 100644 --- a/src/providers/sources/autoembed.ts +++ b/src/providers/sources/autoembed.ts @@ -39,6 +39,7 @@ export const autoembedScraper = makeSourcerer({ id: 'autoembed', name: 'Autoembed', rank: 10, + disabled: true, flags: [flags.CORS_ALLOWED], scrapeMovie: comboScraper, scrapeShow: comboScraper, diff --git a/src/providers/sources/smashystream/index.ts b/src/providers/sources/smashystream/index.ts index 089c777..ba7a94b 100644 --- a/src/providers/sources/smashystream/index.ts +++ b/src/providers/sources/smashystream/index.ts @@ -31,6 +31,7 @@ export const smashyStreamScraper = makeSourcerer({ id: 'smashystream', name: 'SmashyStream', rank: 30, + disabled: true, flags: [flags.CORS_ALLOWED], scrapeMovie: universalScraper, scrapeShow: universalScraper, From 70127b8588ca8a6349a7a6271c3e148b598e17a4 Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 13:45:27 +0100 Subject: [PATCH 10/13] Add proxyDepth option for hls --- src/providers/streams.ts | 1 + src/utils/proxy.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/providers/streams.ts b/src/providers/streams.ts index 17567a4..113b9de 100644 --- a/src/providers/streams.ts +++ b/src/providers/streams.ts @@ -30,6 +30,7 @@ export type FileBasedStream = StreamCommon & { export type HlsBasedStream = StreamCommon & { type: 'hls'; playlist: string; + proxyDepth?: 0 | 1 | 2; }; export type Stream = FileBasedStream | HlsBasedStream; diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts index e57f74a..95dc67e 100644 --- a/src/utils/proxy.ts +++ b/src/utils/proxy.ts @@ -13,12 +13,18 @@ export function setupProxy(stream: Stream): Stream { ? encodeURIComponent(JSON.stringify(stream.headers)) : null; + const options = encodeURIComponent( + JSON.stringify({ + ...(stream.type === 'hls' && { depth: stream.proxyDepth ?? 0 }), + }), + ); + if (stream.type === 'hls') - stream.playlist = `https://proxy.nsbx.ru/hls/${encodeURIComponent(stream.playlist)}/${headers}`; + stream.playlist = `https://proxy.nsbx.ru/hls/${encodeURIComponent(stream.playlist)}/${headers}/${options}`; if (stream.type === 'file') Object.entries(stream.qualities).forEach((entry) => { - entry[1].url = `https://proxy.nsbx.ru/mp4/${encodeURIComponent(entry[1].url)}/${headers}`; + entry[1].url = `https://proxy.nsbx.ru/mp4/${encodeURIComponent(entry[1].url)}/${headers}/${options}`; }); stream.headers = {}; From 83ba2bf8d1bf212a8d05a5363880354acaea2533 Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 13:46:25 +0100 Subject: [PATCH 11/13] Update soaperTv --- src/providers/sources/soapertv/index.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/providers/sources/soapertv/index.ts b/src/providers/sources/soapertv/index.ts index d9d5b77..da86a7d 100644 --- a/src/providers/sources/soapertv/index.ts +++ b/src/providers/sources/soapertv/index.ts @@ -1,10 +1,9 @@ import { load } from 'cheerio'; -import { flags } from '@/entrypoint/utils/targets'; import { Caption, labelToLanguageCode } from '@/providers/captions'; +import { Stream } from '@/providers/streams'; import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; import { NotFoundError } from '@/utils/errors'; -import { convertPlaylistsToDataUrls } from '@/utils/playlist'; import { InfoResponse } from './types'; import { SourcererOutput, makeSourcerer } from '../../base'; @@ -89,20 +88,22 @@ const universalScraper = async (ctx: MovieScrapeContext | ShowScrapeContext): Pr stream: [ { id: 'primary', - playlist: await convertPlaylistsToDataUrls(ctx.proxiedFetcher, `${baseUrl}/${streamResJson.val}`), + playlist: `${baseUrl}/${streamResJson.val}`, type: 'hls', - flags: [flags.CORS_ALLOWED], + proxyDepth: 2, + flags: [], captions, }, ...(streamResJson.val_bak ? [ { id: 'backup', - playlist: await convertPlaylistsToDataUrls(ctx.proxiedFetcher, `${baseUrl}/${streamResJson.val_bak}`), - type: 'hls' as const, - flags: [flags.CORS_ALLOWED], + playlist: `${baseUrl}/${streamResJson.val_bak}`, + type: 'hls', + proxyDepth: 2, + flags: [], captions, - }, + } as Stream, ] : []), ], @@ -113,7 +114,7 @@ export const soaperTvScraper = makeSourcerer({ id: 'soapertv', name: 'SoaperTV', rank: 126, - flags: [flags.CORS_ALLOWED], + flags: [], scrapeMovie: universalScraper, scrapeShow: universalScraper, }); From 88141f74ec19758a4c30892df95e8ae9c7014c52 Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 13:59:10 +0100 Subject: [PATCH 12/13] Update m4u --- src/providers/embeds/playm4u/nm.ts | 6 ++---- src/providers/sources/m4ufree.ts | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/providers/embeds/playm4u/nm.ts b/src/providers/embeds/playm4u/nm.ts index 3a06732..32429fb 100644 --- a/src/providers/embeds/playm4u/nm.ts +++ b/src/providers/embeds/playm4u/nm.ts @@ -1,9 +1,7 @@ import { load } from 'cheerio'; import crypto from 'crypto-js'; -import { flags } from '@/entrypoint/utils/targets'; import { makeEmbed } from '@/providers/base'; -import { convertPlaylistsToDataUrls } from '@/utils/playlist'; const { AES, MD5 } = crypto; @@ -115,9 +113,9 @@ export const playm4uNMScraper = makeEmbed({ { id: 'primary', type: 'hls', - playlist: await convertPlaylistsToDataUrls(ctx.proxiedFetcher, apiRes.data), + playlist: apiRes.data, captions: [], - flags: [flags.CORS_ALLOWED], + flags: [], }, ], }; diff --git a/src/providers/sources/m4ufree.ts b/src/providers/sources/m4ufree.ts index 0617481..6cbb2bc 100644 --- a/src/providers/sources/m4ufree.ts +++ b/src/providers/sources/m4ufree.ts @@ -2,7 +2,6 @@ // thanks Paradox_77 import { load } from 'cheerio'; -import { flags } from '@/entrypoint/utils/targets'; import { SourcererEmbed, makeSourcerer } from '@/providers/base'; import { compareMedia } from '@/utils/compare'; import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; @@ -151,7 +150,7 @@ export const m4uScraper = makeSourcerer({ id: 'm4ufree', name: 'M4UFree', rank: 125, - flags: [flags.CORS_ALLOWED], + flags: [], scrapeMovie: universalScraper, scrapeShow: universalScraper, }); From 62a257165c967816656ec71459768a1a6fab7866 Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 3 Jul 2024 14:04:18 +0100 Subject: [PATCH 13/13] Update proxy again --- src/utils/proxy.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts index 95dc67e..cde7da7 100644 --- a/src/utils/proxy.ts +++ b/src/utils/proxy.ts @@ -2,29 +2,27 @@ import { flags } from '@/entrypoint/utils/targets'; import { Stream } from '@/providers/streams'; export function requiresProxy(stream: Stream): boolean { - if (!stream.flags.includes('cors-allowed') && !!(stream.headers && Object.keys(stream.headers).length > 0)) + if (!stream.flags.includes(flags.CORS_ALLOWED) && !!(stream.headers && Object.keys(stream.headers).length > 0)) return true; return false; } export function setupProxy(stream: Stream): Stream { const headers = - stream.headers && Object.keys(stream.headers).length > 0 - ? encodeURIComponent(JSON.stringify(stream.headers)) - : null; + stream.headers && Object.keys(stream.headers).length > 0 ? btoa(JSON.stringify(stream.headers)) : null; - const options = encodeURIComponent( + const options = btoa( JSON.stringify({ ...(stream.type === 'hls' && { depth: stream.proxyDepth ?? 0 }), }), ); if (stream.type === 'hls') - stream.playlist = `https://proxy.nsbx.ru/hls/${encodeURIComponent(stream.playlist)}/${headers}/${options}`; + stream.playlist = `https://proxy.nsbx.ru/hls/${btoa(stream.playlist)}/${headers}/${options}`; if (stream.type === 'file') Object.entries(stream.qualities).forEach((entry) => { - entry[1].url = `https://proxy.nsbx.ru/mp4/${encodeURIComponent(entry[1].url)}/${headers}/${options}`; + entry[1].url = `https://proxy.nsbx.ru/mp4/${btoa(entry[1].url)}/${headers}/${options}`; }); stream.headers = {};