From 3f6be69742f4b91ab9ccaba4cf65361a472f6b8c Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Sun, 23 Nov 2025 16:03:47 -0700 Subject: [PATCH] fix dropload --- src/providers/all.ts | 2 + src/providers/archive/embeds/dropload.ts | 52 ----------- src/providers/embeds/dropload.ts | 107 +++++++++++++++++++++++ 3 files changed, 109 insertions(+), 52 deletions(-) delete mode 100644 src/providers/archive/embeds/dropload.ts create mode 100644 src/providers/embeds/dropload.ts diff --git a/src/providers/all.ts b/src/providers/all.ts index 722b228..87d6fb6 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -27,6 +27,7 @@ import { } from './embeds/autoembed'; import { cinemaosEmbeds } from './embeds/cinemaos'; import { closeLoadScraper } from './embeds/closeload'; +import { droploadScraper } from './embeds/dropload'; import { filelionsScraper } from './embeds/filelions'; import { madplayBaseEmbed, madplayNsapiEmbed, madplayNsapiVidFastEmbed, madplayRoperEmbed } from './embeds/madplay'; import { mp4hydraServer1Scraper, mp4hydraServer2Scraper } from './embeds/mp4hydra'; @@ -213,5 +214,6 @@ export function gatherAllEmbeds(): Array { vidhideSpanishScraper, vidhideEnglishScraper, filelionsScraper, + droploadScraper, ]; } diff --git a/src/providers/archive/embeds/dropload.ts b/src/providers/archive/embeds/dropload.ts deleted file mode 100644 index c351872..0000000 --- a/src/providers/archive/embeds/dropload.ts +++ /dev/null @@ -1,52 +0,0 @@ -// import { unpack } from 'unpacker'; - -// import { flags } from '@/entrypoint/utils/targets'; - -// import { makeEmbed } from '../base'; - -// const evalCodeRegex = /eval\((.*)\)/g; -// const fileRegex = /file:"(.*?)"/g; -// const tracksRegex = /\{file:"([^"]+)",kind:"thumbnails"\}/g; - -// export const droploadScraper = makeEmbed({ -// id: 'dropload', -// name: 'Dropload', -// rank: 120, -// scrape: async (ctx) => { -// const mainPageRes = await ctx.proxiedFetcher.full(ctx.url, { -// headers: { -// referer: ctx.url, -// }, -// }); -// const mainPageUrl = new URL(mainPageRes.finalUrl); -// const mainPage = mainPageRes.body; - -// const evalCode = mainPage.match(evalCodeRegex); -// if (!evalCode) throw new Error('Failed to find eval code'); -// const unpacked = unpack(evalCode[1]); - -// const file = fileRegex.exec(unpacked); -// const thumbnailTrack = tracksRegex.exec(unpacked); -// if (!file?.[1]) throw new Error('Failed to find file'); - -// return { -// stream: [ -// { -// id: 'primary', -// type: 'hls', -// playlist: file[1], -// flags: [flags.IP_LOCKED, flags.CORS_ALLOWED], -// captions: [], -// ...(thumbnailTrack -// ? { -// thumbnailTrack: { -// type: 'vtt', -// url: mainPageUrl.origin + thumbnailTrack[1], -// }, -// } -// : {}), -// }, -// ], -// }; -// }, -// }); diff --git a/src/providers/embeds/dropload.ts b/src/providers/embeds/dropload.ts new file mode 100644 index 0000000..b34a568 --- /dev/null +++ b/src/providers/embeds/dropload.ts @@ -0,0 +1,107 @@ +import { load } from 'cheerio'; +import { unpack } from 'unpacker'; + +import { flags } from '@/entrypoint/utils/targets'; +import { NotFoundError } from '@/utils/errors'; + +import { makeEmbed } from '../base'; + +const tracksRegex = /\{file:"([^"]+)",kind:"thumbnails"\}/g; + +function extractUrlFromPacked(html: string, patterns: RegExp[]): string { + const $ = load(html); + + // Find packed script similar to filemoon approach + const packedScript = $('script') + .filter((_, el) => { + const htmlContent = $(el).html(); + return htmlContent != null && htmlContent.includes('eval(function(p,a,c,k,e,d)'); + }) + .first() + .html(); + + if (!packedScript) throw new NotFoundError('Packed script not found'); + + try { + const unpacked = unpack(packedScript); + for (const pattern of patterns) { + const match = unpacked.match(pattern); + if (match?.[1]) { + return match[1]; + } + } + } catch (error) { + // If unpacking fails, try alternative patterns or fallback + console.warn('Unpacking failed, trying fallback patterns'); + } + + throw new NotFoundError('Failed to find file URL in packed code'); +} + +function extractThumbnailTrack(html: string): string | null { + const $ = load(html); + + // Find packed script + const packedScript = $('script') + .filter((_, el) => { + const htmlContent = $(el).html(); + return htmlContent != null && htmlContent.includes('eval(function(p,a,c,k,e,d)'); + }) + .first() + .html(); + + if (!packedScript) return null; + + try { + const unpacked = unpack(packedScript); + const thumbnailMatch = tracksRegex.exec(unpacked); + return thumbnailMatch?.[1] || null; + } catch (error) { + return null; + } +} + +export const droploadScraper = makeEmbed({ + id: 'dropload', + name: 'Dropload', + rank: 120, + scrape: async (ctx) => { + const headers = { + referer: ctx.url, + }; + + const html = await ctx.proxiedFetcher(ctx.url, { + headers, + }); + + if (html.includes('File Not Found') || html.includes('Pending in queue')) { + throw new NotFoundError(); + } + + // Extract playlist URL from packed JavaScript + const playlistUrl = extractUrlFromPacked(html, [/sources:\[{file:"(.*?)"/]); + + const mainPageUrl = new URL(ctx.url); + + // Extract thumbnail track if available + const thumbnailTrack = extractThumbnailTrack(html); + + return { + stream: [ + { + id: 'primary', + type: 'hls', + playlist: playlistUrl, + flags: [flags.CORS_ALLOWED], + captions: [], + ...(thumbnailTrack && { + thumbnailTrack: { + type: 'vtt', + url: mainPageUrl.origin + thumbnailTrack, + }, + }), + }, + ], + }; + }, +});