From a0d4cb824371eed93334b63ba71fc61f2aca736e Mon Sep 17 00:00:00 2001 From: TPN Date: Thu, 6 Jun 2024 20:51:13 +0530 Subject: [PATCH 1/3] Add Autoembed source and split its languages into embeds --- src/providers/all.ts | 12 ++++++ src/providers/embeds/autoembed/bengali.ts | 15 ++++++++ src/providers/embeds/autoembed/english.ts | 21 +++++++++++ src/providers/embeds/autoembed/hindi.ts | 15 ++++++++ src/providers/embeds/autoembed/tamil.ts | 15 ++++++++ src/providers/embeds/autoembed/telugu.ts | 15 ++++++++ src/providers/sources/autoembed.ts | 45 +++++++++++++++++++++++ 7 files changed, 138 insertions(+) create mode 100644 src/providers/embeds/autoembed/bengali.ts create mode 100644 src/providers/embeds/autoembed/english.ts create mode 100644 src/providers/embeds/autoembed/hindi.ts create mode 100644 src/providers/embeds/autoembed/tamil.ts create mode 100644 src/providers/embeds/autoembed/telugu.ts create mode 100644 src/providers/sources/autoembed.ts diff --git a/src/providers/all.ts b/src/providers/all.ts index 33af334..cdc5402 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -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 { autoembedScraper } from '@/providers/sources/autoembed'; import { flixhqScraper } from '@/providers/sources/flixhq/index'; import { goMoviesScraper } from '@/providers/sources/gomovies/index'; import { insertunitScraper } from '@/providers/sources/insertunit'; @@ -24,6 +25,11 @@ import { tugaflixScraper } from '@/providers/sources/tugaflix'; import { vidsrcScraper } from '@/providers/sources/vidsrc/index'; import { zoechipScraper } from '@/providers/sources/zoechip'; +import { autoembedBenagaliScraper } from './embeds/autoembed/bengali'; +import { autoembedEnglishScraper } from './embeds/autoembed/english'; +import { autoembedHindiScraper } from './embeds/autoembed/hindi'; +import { autoembedTamilScraper } from './embeds/autoembed/tamil'; +import { autoembedTeluguScraper } from './embeds/autoembed/telugu'; import { bflixScraper } from './embeds/bflix'; import { closeLoadScraper } from './embeds/closeload'; import { fileMoonScraper } from './embeds/filemoon'; @@ -78,6 +84,7 @@ export function gatherAllSources(): Array { insertunitScraper, nitesScraper, soaperTvScraper, + autoembedScraper, tugaflixScraper, ]; } @@ -117,5 +124,10 @@ export function gatherAllEmbeds(): Array { bflixScraper, playm4uNMScraper, hydraxScraper, + autoembedEnglishScraper, + autoembedHindiScraper, + autoembedBenagaliScraper, + autoembedTamilScraper, + autoembedTeluguScraper, ]; } diff --git a/src/providers/embeds/autoembed/bengali.ts b/src/providers/embeds/autoembed/bengali.ts new file mode 100644 index 0000000..50e5376 --- /dev/null +++ b/src/providers/embeds/autoembed/bengali.ts @@ -0,0 +1,15 @@ +import { makeEmbed } from '@/providers/base'; + +import { autoembedEnglishScraper } from './english'; + +export const autoembedBenagaliScraper = makeEmbed({ + id: 'autoembed-bengali', + name: 'Bengali', + rank: 7, + async scrape(ctx) { + const result = await autoembedEnglishScraper.scrape(ctx); + return { + stream: result.stream, + }; + }, +}); diff --git a/src/providers/embeds/autoembed/english.ts b/src/providers/embeds/autoembed/english.ts new file mode 100644 index 0000000..168ae0d --- /dev/null +++ b/src/providers/embeds/autoembed/english.ts @@ -0,0 +1,21 @@ +import { flags } from '@/entrypoint/utils/targets'; +import { makeEmbed } from '@/providers/base'; + +export const autoembedEnglishScraper = makeEmbed({ + id: 'autoembed-english', + name: 'English', + rank: 10, + scrape: async (ctx) => { + return { + stream: [ + { + id: 'primary', + type: 'hls', + playlist: ctx.url, + flags: [flags.CORS_ALLOWED], + captions: [], + }, + ], + }; + }, +}); diff --git a/src/providers/embeds/autoembed/hindi.ts b/src/providers/embeds/autoembed/hindi.ts new file mode 100644 index 0000000..2532d47 --- /dev/null +++ b/src/providers/embeds/autoembed/hindi.ts @@ -0,0 +1,15 @@ +import { makeEmbed } from '@/providers/base'; + +import { autoembedEnglishScraper } from './english'; + +export const autoembedHindiScraper = makeEmbed({ + id: 'autoembed-hindi', + name: 'Hindi', + rank: 9, + async scrape(ctx) { + const result = await autoembedEnglishScraper.scrape(ctx); + return { + stream: result.stream, + }; + }, +}); diff --git a/src/providers/embeds/autoembed/tamil.ts b/src/providers/embeds/autoembed/tamil.ts new file mode 100644 index 0000000..c395b8e --- /dev/null +++ b/src/providers/embeds/autoembed/tamil.ts @@ -0,0 +1,15 @@ +import { makeEmbed } from '@/providers/base'; + +import { autoembedEnglishScraper } from './english'; + +export const autoembedTamilScraper = makeEmbed({ + id: 'autoembed-tamil', + name: 'Tamil', + rank: 8, + async scrape(ctx) { + const result = await autoembedEnglishScraper.scrape(ctx); + return { + stream: result.stream, + }; + }, +}); diff --git a/src/providers/embeds/autoembed/telugu.ts b/src/providers/embeds/autoembed/telugu.ts new file mode 100644 index 0000000..52dc608 --- /dev/null +++ b/src/providers/embeds/autoembed/telugu.ts @@ -0,0 +1,15 @@ +import { makeEmbed } from '@/providers/base'; + +import { autoembedEnglishScraper } from './english'; + +export const autoembedTeluguScraper = makeEmbed({ + id: 'autoembed-telugu', + name: 'Telugu', + rank: 6, + async scrape(ctx) { + const result = await autoembedEnglishScraper.scrape(ctx); + return { + stream: result.stream, + }; + }, +}); diff --git a/src/providers/sources/autoembed.ts b/src/providers/sources/autoembed.ts new file mode 100644 index 0000000..1aa4796 --- /dev/null +++ b/src/providers/sources/autoembed.ts @@ -0,0 +1,45 @@ +import { flags } from '@/entrypoint/utils/targets'; +import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base'; +import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; +import { NotFoundError } from '@/utils/errors'; + +const baseUrl = 'https://autoembed.cc/'; + +async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise { + const playerPage = await ctx.proxiedFetcher(`/embed/player.php`, { + baseUrl, + query: { + id: ctx.media.tmdbId, + ...(ctx.media.type === 'show' && { + s: ctx.media.season.number.toString(), + e: ctx.media.episode.number.toString(), + }), + }, + }); + + const fileDataMatch = playerPage.match(/"file": (\[.*?\])/s); + if (!fileDataMatch[1]) throw new NotFoundError('No data found'); + + const fileData: { title: string; file: string }[] = JSON.parse(fileDataMatch[1].replace(/,\s*\]$/, ']')); + + const embeds: SourcererEmbed[] = []; + + for (const stream of fileData) { + const url = stream.file; + if (!url) continue; + embeds.push({ embedId: `autoembed-${stream.title.toLowerCase().trim()}`, url }); + } + + return { + embeds, + }; +} + +export const autoembedScraper = makeSourcerer({ + id: 'autoembed', + name: 'Autoembed', + rank: 10, + flags: [flags.CORS_ALLOWED], + scrapeMovie: comboScraper, + scrapeShow: comboScraper, +}); From cf161e7cd5d66319ec2d28e294150b0b0dbbcf2b Mon Sep 17 00:00:00 2001 From: TPN Date: Thu, 6 Jun 2024 21:16:18 +0530 Subject: [PATCH 2/3] Merge all autoembed embeds in one file --- src/providers/all.ts | 14 +++--- src/providers/embeds/autoembed.ts | 54 +++++++++++++++++++++++ src/providers/embeds/autoembed/bengali.ts | 15 ------- src/providers/embeds/autoembed/english.ts | 21 --------- src/providers/embeds/autoembed/hindi.ts | 15 ------- src/providers/embeds/autoembed/tamil.ts | 15 ------- src/providers/embeds/autoembed/telugu.ts | 15 ------- 7 files changed, 62 insertions(+), 87 deletions(-) create mode 100644 src/providers/embeds/autoembed.ts delete mode 100644 src/providers/embeds/autoembed/bengali.ts delete mode 100644 src/providers/embeds/autoembed/english.ts delete mode 100644 src/providers/embeds/autoembed/hindi.ts delete mode 100644 src/providers/embeds/autoembed/tamil.ts delete mode 100644 src/providers/embeds/autoembed/telugu.ts diff --git a/src/providers/all.ts b/src/providers/all.ts index cdc5402..90903a6 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -25,11 +25,13 @@ import { tugaflixScraper } from '@/providers/sources/tugaflix'; import { vidsrcScraper } from '@/providers/sources/vidsrc/index'; import { zoechipScraper } from '@/providers/sources/zoechip'; -import { autoembedBenagaliScraper } from './embeds/autoembed/bengali'; -import { autoembedEnglishScraper } from './embeds/autoembed/english'; -import { autoembedHindiScraper } from './embeds/autoembed/hindi'; -import { autoembedTamilScraper } from './embeds/autoembed/tamil'; -import { autoembedTeluguScraper } from './embeds/autoembed/telugu'; +import { + autoembedBengaliScraper, + autoembedEnglishScraper, + autoembedHindiScraper, + autoembedTamilScraper, + autoembedTeluguScraper, +} from './embeds/autoembed'; import { bflixScraper } from './embeds/bflix'; import { closeLoadScraper } from './embeds/closeload'; import { fileMoonScraper } from './embeds/filemoon'; @@ -126,7 +128,7 @@ export function gatherAllEmbeds(): Array { hydraxScraper, autoembedEnglishScraper, autoembedHindiScraper, - autoembedBenagaliScraper, + autoembedBengaliScraper, autoembedTamilScraper, autoembedTeluguScraper, ]; diff --git a/src/providers/embeds/autoembed.ts b/src/providers/embeds/autoembed.ts new file mode 100644 index 0000000..50d153a --- /dev/null +++ b/src/providers/embeds/autoembed.ts @@ -0,0 +1,54 @@ +import { flags } from '@/entrypoint/utils/targets'; +import { makeEmbed } from '@/providers/base'; + +const providers = [ + { + id: 'autoembed-english', + rank: 10, + }, + { + id: 'autoembed-hindi', + rank: 9, + }, + { + id: 'autoembed-tamil', + rank: 8, + }, + { + id: 'autoembed-telugu', + rank: 7, + }, + { + id: 'autoembed-bengali', + rank: 6, + }, +]; + +function embed(provider: { id: string; rank: number }) { + return makeEmbed({ + id: provider.id, + name: provider.id.charAt(0).toUpperCase() + provider.id.slice(1), + rank: provider.rank, + async scrape(ctx) { + return { + stream: [ + { + id: 'primary', + type: 'hls', + playlist: ctx.url, + flags: [flags.CORS_ALLOWED], + captions: [], + }, + ], + }; + }, + }); +} + +export const [ + autoembedEnglishScraper, + autoembedHindiScraper, + autoembedBengaliScraper, + autoembedTamilScraper, + autoembedTeluguScraper, +] = providers.map(embed); diff --git a/src/providers/embeds/autoembed/bengali.ts b/src/providers/embeds/autoembed/bengali.ts deleted file mode 100644 index 50e5376..0000000 --- a/src/providers/embeds/autoembed/bengali.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { makeEmbed } from '@/providers/base'; - -import { autoembedEnglishScraper } from './english'; - -export const autoembedBenagaliScraper = makeEmbed({ - id: 'autoembed-bengali', - name: 'Bengali', - rank: 7, - async scrape(ctx) { - const result = await autoembedEnglishScraper.scrape(ctx); - return { - stream: result.stream, - }; - }, -}); diff --git a/src/providers/embeds/autoembed/english.ts b/src/providers/embeds/autoembed/english.ts deleted file mode 100644 index 168ae0d..0000000 --- a/src/providers/embeds/autoembed/english.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { flags } from '@/entrypoint/utils/targets'; -import { makeEmbed } from '@/providers/base'; - -export const autoembedEnglishScraper = makeEmbed({ - id: 'autoembed-english', - name: 'English', - rank: 10, - scrape: async (ctx) => { - return { - stream: [ - { - id: 'primary', - type: 'hls', - playlist: ctx.url, - flags: [flags.CORS_ALLOWED], - captions: [], - }, - ], - }; - }, -}); diff --git a/src/providers/embeds/autoembed/hindi.ts b/src/providers/embeds/autoembed/hindi.ts deleted file mode 100644 index 2532d47..0000000 --- a/src/providers/embeds/autoembed/hindi.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { makeEmbed } from '@/providers/base'; - -import { autoembedEnglishScraper } from './english'; - -export const autoembedHindiScraper = makeEmbed({ - id: 'autoembed-hindi', - name: 'Hindi', - rank: 9, - async scrape(ctx) { - const result = await autoembedEnglishScraper.scrape(ctx); - return { - stream: result.stream, - }; - }, -}); diff --git a/src/providers/embeds/autoembed/tamil.ts b/src/providers/embeds/autoembed/tamil.ts deleted file mode 100644 index c395b8e..0000000 --- a/src/providers/embeds/autoembed/tamil.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { makeEmbed } from '@/providers/base'; - -import { autoembedEnglishScraper } from './english'; - -export const autoembedTamilScraper = makeEmbed({ - id: 'autoembed-tamil', - name: 'Tamil', - rank: 8, - async scrape(ctx) { - const result = await autoembedEnglishScraper.scrape(ctx); - return { - stream: result.stream, - }; - }, -}); diff --git a/src/providers/embeds/autoembed/telugu.ts b/src/providers/embeds/autoembed/telugu.ts deleted file mode 100644 index 52dc608..0000000 --- a/src/providers/embeds/autoembed/telugu.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { makeEmbed } from '@/providers/base'; - -import { autoembedEnglishScraper } from './english'; - -export const autoembedTeluguScraper = makeEmbed({ - id: 'autoembed-telugu', - name: 'Telugu', - rank: 6, - async scrape(ctx) { - const result = await autoembedEnglishScraper.scrape(ctx); - return { - stream: result.stream, - }; - }, -}); From b04c921b5533e6f53a58c3a0406d90ad2f076c05 Mon Sep 17 00:00:00 2001 From: Exodus-MW Date: Fri, 7 Jun 2024 23:28:58 +0530 Subject: [PATCH 3/3] proxy nsbx requests --- src/providers/embeds/nsbx.ts | 10 +++------- src/providers/sources/nsbx.ts | 9 +-------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/providers/embeds/nsbx.ts b/src/providers/embeds/nsbx.ts index 397a1c9..47833db 100644 --- a/src/providers/embeds/nsbx.ts +++ b/src/providers/embeds/nsbx.ts @@ -1,5 +1,5 @@ import { EmbedOutput, makeEmbed } from '@/providers/base'; -import { baseUrl, headers } from '@/providers/sources/nsbx'; +import { baseUrl } from '@/providers/sources/nsbx'; import { NotFoundError } from '@/utils/errors'; const providers = [ @@ -20,9 +20,8 @@ function embed(provider: { id: string; rank: number }) { rank: provider.rank, disabled: false, async scrape(ctx) { - const search = await ctx.fetcher.full( + const search = await ctx.proxiedFetcher.full( `${baseUrl}/search?query=${encodeURIComponent(ctx.url)}&provider=${provider.id}`, - { headers }, ); if (search.statusCode === 429) { @@ -33,11 +32,8 @@ function embed(provider: { id: string; rank: number }) { ctx.progress(50); - const result = await ctx.fetcher( + const result = await ctx.proxiedFetcher( `${baseUrl}/provider?resourceId=${encodeURIComponent(search.body.url)}&provider=${provider.id}`, - { - headers, - }, ); ctx.progress(100); diff --git a/src/providers/sources/nsbx.ts b/src/providers/sources/nsbx.ts index 57152ed..780bb1a 100644 --- a/src/providers/sources/nsbx.ts +++ b/src/providers/sources/nsbx.ts @@ -5,11 +5,6 @@ import { NotFoundError } from '@/utils/errors'; export const baseUrl = 'https://api.nsbx.ru'; -export const headers = { - Origin: 'https://extension.works.again.with.nsbx', - Referer: 'https://extension.works.again.with.nsbx', -}; - async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise { const query = { title: ctx.media.title, @@ -26,9 +21,7 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis query.episode = ctx.media.episode.number.toString(); } - const res = await ctx.fetcher(`${baseUrl}/status`, { - headers, - }); + const res = await ctx.proxiedFetcher(`${baseUrl}/status`); if (res.providers?.length === 0) { throw new NotFoundError('No providers available');