mirror of
https://github.com/p-stream/providers.git
synced 2026-01-11 20:10:33 +00:00
fix dropload
This commit is contained in:
parent
2f3a73c3d2
commit
3f6be69742
3 changed files with 109 additions and 52 deletions
|
|
@ -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<Embed> {
|
|||
vidhideSpanishScraper,
|
||||
vidhideEnglishScraper,
|
||||
filelionsScraper,
|
||||
droploadScraper,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<string>(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],
|
||||
// },
|
||||
// }
|
||||
// : {}),
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
// },
|
||||
// });
|
||||
107
src/providers/embeds/dropload.ts
Normal file
107
src/providers/embeds/dropload.ts
Normal file
|
|
@ -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<string>(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,
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
});
|
||||
Loading…
Reference in a new issue