From 06e0ba23d7a83ec981c227fe02357d6c040b1100 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:07:24 +0000 Subject: [PATCH] fix(extractor): support Dropload with missing height/size info --- src/extractor/Dropload.test.ts | 4 + src/extractor/Dropload.ts | 18 +- .../Dropload/https:dropload.iogf2apij3ql37 | 460 ++++++++++++++++++ ...i0.0andsp0andii2.184.0.222andp1ds3andp2ds3 | 5 + .../__snapshots__/Dropload.test.ts.snap | 17 + 5 files changed, 498 insertions(+), 6 deletions(-) create mode 100644 src/extractor/__fixtures__/Dropload/https:dropload.iogf2apij3ql37 create mode 100644 src/extractor/__fixtures__/Dropload/https:ds16.dropcdn.iohls20200314gf2apij3ql37_hmaster.m3u8tjq0VCV2dOyLIIH07IGIpzruCXvbfdVqzGLWfMeo00AMands1759845990ande14400andf1571895andsrvds3andi0.0andsp0andii2.184.0.222andp1ds3andp2ds3 diff --git a/src/extractor/Dropload.test.ts b/src/extractor/Dropload.test.ts index ad28e55..b7687b2 100644 --- a/src/extractor/Dropload.test.ts +++ b/src/extractor/Dropload.test.ts @@ -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(); }); diff --git a/src/extractor/Dropload.ts b/src/extractor/Dropload.ts index 57d9d5e..43d2a5b 100644 --- a/src/extractor/Dropload.ts +++ b/src/extractor/Dropload.ts @@ -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 }), }, }, ]; diff --git a/src/extractor/__fixtures__/Dropload/https:dropload.iogf2apij3ql37 b/src/extractor/__fixtures__/Dropload/https:dropload.iogf2apij3ql37 new file mode 100644 index 0000000..baa87a3 --- /dev/null +++ b/src/extractor/__fixtures__/Dropload/https:dropload.iogf2apij3ql37 @@ -0,0 +1,460 @@ + + + +
+ +