From fed8678ef1d8b05e187e149b1f339885c0661750 Mon Sep 17 00:00:00 2001 From: Paradox-77 Date: Thu, 14 Mar 2024 22:45:19 +0530 Subject: [PATCH 1/5] Fix embedUrl matching for Vidplay and Filemoon sources --- src/providers/sources/vidsrcto/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/sources/vidsrcto/index.ts b/src/providers/sources/vidsrcto/index.ts index 94edc3d..3739ab5 100644 --- a/src/providers/sources/vidsrcto/index.ts +++ b/src/providers/sources/vidsrcto/index.ts @@ -52,7 +52,7 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr for (const source of sources.result) { if (source.title === 'Vidplay') { - const embedUrl = embedUrls.find((v) => v.includes('vidplay')); + const embedUrl = embedUrls.find((v) => v.match(/https:\/\/(?:[a-zA-Z0-9]{10})\./)); if (!embedUrl) continue; embeds.push({ embedId: 'vidplay', @@ -61,7 +61,7 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr } if (source.title === 'Filemoon') { - const embedUrl = embedUrls.find((v) => v.includes('filemoon')); + const embedUrl = embedUrls.find((v) => v.includes('kerapoxy')); if (!embedUrl) continue; const fullUrl = new URL(embedUrl); if (subtitleUrl) fullUrl.searchParams.set('sub.info', subtitleUrl); From bd0f1e2ddc9d0e14bae0c5f5a77cdf79a4a5b544 Mon Sep 17 00:00:00 2001 From: Paradox-77 Date: Fri, 15 Mar 2024 00:18:30 +0530 Subject: [PATCH 2/5] Refactored Source to Url association, no longer breaks if domain changes --- src/providers/sources/vidsrcto/index.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/providers/sources/vidsrcto/index.ts b/src/providers/sources/vidsrcto/index.ts index 3739ab5..fcc7197 100644 --- a/src/providers/sources/vidsrcto/index.ts +++ b/src/providers/sources/vidsrcto/index.ts @@ -33,7 +33,7 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr if (sources.status !== 200) throw new Error('No sources found'); const embeds: SourcererEmbed[] = []; - const embedUrls = []; + const embedArr = []; for (const source of sources.result) { const sourceRes = await ctx.proxiedFetcher(`/ajax/embed/source/${source.id}`, { baseUrl: vidSrcToBase, @@ -42,28 +42,26 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr }, }); const decryptedUrl = decryptSourceUrl(sourceRes.result.url); - embedUrls.push(decryptedUrl); + embedArr.push({ source: source.title, url: decryptedUrl }); } // Originally Filemoon does not have subtitles. But we can use the ones from Vidplay. - const urlWithSubtitles = embedUrls.find((v) => v.includes('sub.info')); + const urlWithSubtitles = embedArr.find((v) => v.url.includes('sub.info'))?.url; let subtitleUrl: string | null = null; if (urlWithSubtitles) subtitleUrl = new URL(urlWithSubtitles).searchParams.get('sub.info'); - for (const source of sources.result) { - if (source.title === 'Vidplay') { - const embedUrl = embedUrls.find((v) => v.match(/https:\/\/(?:[a-zA-Z0-9]{10})\./)); - if (!embedUrl) continue; + for (const embedObj of embedArr) { + if (embedObj.source === 'Vidplay') { + const fullUrl = new URL(embedObj.url); + if (subtitleUrl) fullUrl.searchParams.set('sub.info', subtitleUrl); embeds.push({ embedId: 'vidplay', - url: embedUrl, + url: fullUrl.toString(), }); } - if (source.title === 'Filemoon') { - const embedUrl = embedUrls.find((v) => v.includes('kerapoxy')); - if (!embedUrl) continue; - const fullUrl = new URL(embedUrl); + if (embedObj.source === 'Filemoon') { + const fullUrl = new URL(embedObj.url); if (subtitleUrl) fullUrl.searchParams.set('sub.info', subtitleUrl); embeds.push({ embedId: 'filemoon', From 44686f76deb15aa5cd4915abe6b23e5322c98316 Mon Sep 17 00:00:00 2001 From: Paradox-77 Date: Fri, 15 Mar 2024 00:41:32 +0530 Subject: [PATCH 3/5] Fixed vidplay subtitle oversight and refactored filemoon url to use vidplay's subtitles --- src/providers/sources/vidsrcto/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/providers/sources/vidsrcto/index.ts b/src/providers/sources/vidsrcto/index.ts index fcc7197..b0b95f9 100644 --- a/src/providers/sources/vidsrcto/index.ts +++ b/src/providers/sources/vidsrcto/index.ts @@ -45,15 +45,9 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr embedArr.push({ source: source.title, url: decryptedUrl }); } - // Originally Filemoon does not have subtitles. But we can use the ones from Vidplay. - const urlWithSubtitles = embedArr.find((v) => v.url.includes('sub.info'))?.url; - let subtitleUrl: string | null = null; - if (urlWithSubtitles) subtitleUrl = new URL(urlWithSubtitles).searchParams.get('sub.info'); - for (const embedObj of embedArr) { if (embedObj.source === 'Vidplay') { const fullUrl = new URL(embedObj.url); - if (subtitleUrl) fullUrl.searchParams.set('sub.info', subtitleUrl); embeds.push({ embedId: 'vidplay', url: fullUrl.toString(), @@ -62,6 +56,9 @@ const universalScraper = async (ctx: ShowScrapeContext | MovieScrapeContext): Pr if (embedObj.source === 'Filemoon') { const fullUrl = new URL(embedObj.url); + // Originally Filemoon does not have subtitles. But we can use the ones from Vidplay. + const urlWithSubtitles = embedArr.find((v) => v.source === 'Vidplay' && v.url.includes('sub.info'))?.url; + const subtitleUrl = urlWithSubtitles ? new URL(urlWithSubtitles).searchParams.get('sub.info') : null; if (subtitleUrl) fullUrl.searchParams.set('sub.info', subtitleUrl); embeds.push({ embedId: 'filemoon', From db4a27e51a908076651df3713c3e18f52080fe12 Mon Sep 17 00:00:00 2001 From: Jorrin Date: Thu, 14 Mar 2024 20:45:40 +0100 Subject: [PATCH 4/5] add cors allowed flags --- src/providers/embeds/filemoon/index.ts | 3 ++- src/providers/embeds/vidplay/index.ts | 9 +++------ src/providers/sources/vidsrcto/index.ts | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/providers/embeds/filemoon/index.ts b/src/providers/embeds/filemoon/index.ts index 9f96a07..4622959 100644 --- a/src/providers/embeds/filemoon/index.ts +++ b/src/providers/embeds/filemoon/index.ts @@ -1,6 +1,7 @@ import { unpack } from 'unpacker'; import { SubtitleResult } from './types'; +import { flags } from '../../../../lib'; import { makeEmbed } from '../../base'; import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '../../captions'; @@ -49,7 +50,7 @@ export const fileMoonScraper = makeEmbed({ id: 'primary', type: 'hls', playlist: file[1], - flags: [], + flags: [flags.CORS_ALLOWED], captions, }, ], diff --git a/src/providers/embeds/vidplay/index.ts b/src/providers/embeds/vidplay/index.ts index 48af6c1..045e19e 100644 --- a/src/providers/embeds/vidplay/index.ts +++ b/src/providers/embeds/vidplay/index.ts @@ -1,7 +1,8 @@ +import { flags } from '@/entrypoint/utils/targets'; import { makeEmbed } from '@/providers/base'; import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions'; -import { getFileUrl, referer } from './common'; +import { getFileUrl } from './common'; import { SubtitleResult, VidplaySourceResponse } from './types'; export const vidplayScraper = makeEmbed({ @@ -44,12 +45,8 @@ export const vidplayScraper = makeEmbed({ id: 'primary', type: 'hls', playlist: source, - flags: [], + flags: [flags.CORS_ALLOWED], captions, - preferredHeaders: { - Referer: referer, - Origin: referer, - }, }, ], }; diff --git a/src/providers/sources/vidsrcto/index.ts b/src/providers/sources/vidsrcto/index.ts index b0b95f9..c6c9fb5 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'; @@ -77,6 +78,6 @@ export const vidSrcToScraper = makeSourcerer({ name: 'VidSrcTo', scrapeMovie: universalScraper, scrapeShow: universalScraper, - flags: [], + flags: [flags.CORS_ALLOWED], rank: 300, }); From d776069613451a7eac88296142a0c677e4bd6276 Mon Sep 17 00:00:00 2001 From: Jorrin Date: Thu, 14 Mar 2024 20:51:49 +0100 Subject: [PATCH 5/5] fix build --- src/providers/embeds/filemoon/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/providers/embeds/filemoon/index.ts b/src/providers/embeds/filemoon/index.ts index 4622959..3f8a2f3 100644 --- a/src/providers/embeds/filemoon/index.ts +++ b/src/providers/embeds/filemoon/index.ts @@ -1,7 +1,8 @@ import { unpack } from 'unpacker'; +import { flags } from '@/entrypoint/utils/targets'; + import { SubtitleResult } from './types'; -import { flags } from '../../../../lib'; import { makeEmbed } from '../../base'; import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '../../captions';