fix(extractor): support Dropload with missing height/size info

This commit is contained in:
WebStreamr 2025-10-07 14:07:24 +00:00
parent 8fb3320868
commit 06e0ba23d7
No known key found for this signature in database
5 changed files with 498 additions and 6 deletions

View file

@ -14,6 +14,10 @@ describe('Dropload', () => {
expect(await extractorRegistry.handle(ctx, new URL('https://dropload.io/embed-lyo2h1snpe5c.html'))).toMatchSnapshot();
});
test('dropload unknown height and size', async () => {
expect(await extractorRegistry.handle(ctx, new URL('https://dropload.io/gf2apij3ql37'))).toMatchSnapshot();
});
test('file not found', async () => {
expect(await extractorRegistry.handle(ctx, new URL('https://dropload.io/asdfghijklmn.html'))).toMatchSnapshot();
});

View file

@ -2,7 +2,7 @@ import bytes from 'bytes';
import * as cheerio from 'cheerio';
import { NotFoundError } from '../error';
import { Context, Format, Meta, UrlResult } from '../types';
import { extractUrlFromPacked } from '../utils';
import { extractUrlFromPacked, guessHeightFromPlaylist } from '../utils';
import { Extractor } from './Extractor';
export class Dropload extends Extractor {
@ -27,25 +27,31 @@ export class Dropload extends Extractor {
throw new NotFoundError();
}
const heightMatch = html.match(/\d{3,}x(\d{3,}),/) as string[];
const playlistUrl = extractUrlFromPacked(html, [/sources:\[{file:"(.*?)"/]);
const sizeMatch = html.match(/([\d.]+ ?[GM]B)/) as string[];
const heightMatch = html.match(/\d{3,}x(\d{3,}),/);
const height = heightMatch
? parseInt(heightMatch[1] as string)
: await guessHeightFromPlaylist(ctx, this.fetcher, playlistUrl);
const sizeMatch = html.match(/([\d.]+ ?[GM]B)/);
const size = sizeMatch ? bytes.parse(sizeMatch[1] as string) as number : undefined;
const $ = cheerio.load(html);
const title = $('.videoplayer h1').text().trim();
return [
{
url: extractUrlFromPacked(html, [/sources:\[{file:"(.*?)"/]),
url: playlistUrl,
format: Format.hls,
label: this.label,
sourceId: `${this.id}_${meta.countryCodes?.join('_')}`,
ttl: this.ttl,
meta: {
...meta,
bytes: bytes.parse(sizeMatch[1] as string) as number,
height: parseInt(heightMatch[1] as string),
title,
...(size && { bytes: size }),
...(height && { height }),
},
},
];

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,5 @@
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3955353,RESOLUTION=1920x800,FRAME-RATE=23.974,CODECS="avc1.640028,mp4a.40.2",VIDEO-RANGE=SDR
index-v1-a1.m3u8?t=jq0VCV2dOyLIIH07IGIpzruCXvbfdVqzGLWfMeo00AM&s=1759845990&e=14400&f=1571895&srv=ds3&i=0.0&sp=0&ii=2.184.0.222&p1=ds3&p2=ds3
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=68483,RESOLUTION=1920x800,CODECS="avc1.640028",URI="iframes-v1-a1.m3u8?t=jq0VCV2dOyLIIH07IGIpzruCXvbfdVqzGLWfMeo00AM&s=1759845990&e=14400&f=1571895&srv=ds3&i=0.0&sp=0&ii=2.184.0.222&p1=ds3&p2=ds3",VIDEO-RANGE=SDR

View file

@ -18,6 +18,23 @@ exports[`Dropload download URL 1`] = `
]
`;
exports[`Dropload dropload unknown height and size 1`] = `
[
{
"format": "hls",
"label": "Dropload",
"meta": {
"countryCodes": [],
"height": 800,
"title": "The Lost Bus 2025 1080p WEBRip x265",
},
"sourceId": "dropload_",
"ttl": 10800000,
"url": "https://ds16.dropcdn.io/hls2/02/00314/gf2apij3ql37_h/master.m3u8?t=jq0VCV2dOyLIIH07IGIpzruCXvbfdVqzGLWfMeo00AM&s=1759845990&e=14400&f=1571895&srv=ds3&i=0.0&sp=0&ii=2.184.0.222&p1=ds3&p2=ds3",
},
]
`;
exports[`Dropload dropload.io 1`] = `
[
{