From b3db546e00413f68d04ee53851b8b5cff6db9152 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Tue, 7 Oct 2025 13:25:18 +0000 Subject: [PATCH] perf(extractor): do not guess resolution via MFP playlist for LuluStream --- src/extractor/LuluStream.test.ts | 4 ++++ src/extractor/LuluStream.ts | 12 ++++++------ ...w.test.org-a2f2340c4a16e932bc5ea0c234dda69f | 4 ---- .../__snapshots__/LuluStream.test.ts.snap | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) delete mode 100644 src/extractor/__fixtures__/LuluStream/https:mediaflow.test.org-a2f2340c4a16e932bc5ea0c234dda69f diff --git a/src/extractor/LuluStream.test.ts b/src/extractor/LuluStream.test.ts index dd4abdc..5ccffd2 100644 --- a/src/extractor/LuluStream.test.ts +++ b/src/extractor/LuluStream.test.ts @@ -14,6 +14,10 @@ describe('LuluStream', () => { expect(await extractorRegistry.handle(ctx, new URL('https://streamhihi.com/d/mk9m58lz8ts6'))).toMatchSnapshot(); }); + test('streamhihi', async () => { + expect(await extractorRegistry.handle(ctx, new URL('https://streamhihi.com/mk9m58lz8ts6'))).toMatchSnapshot(); + }); + test('no such file', async () => { expect(await extractorRegistry.handle(ctx, new URL('https://lulustream.com/e/uthq0o0sljnx'))).toMatchSnapshot(); }); diff --git a/src/extractor/LuluStream.ts b/src/extractor/LuluStream.ts index 5bc9bcf..465dded 100644 --- a/src/extractor/LuluStream.ts +++ b/src/extractor/LuluStream.ts @@ -4,8 +4,6 @@ import { NotFoundError } from '../error'; import { Context, Format, Meta, UrlResult } from '../types'; import { buildMediaFlowProxyExtractorStreamUrl, - guessHeightFromPlaylist, - MEDIAFLOW_DEFAULT_INIT, supportsMediaFlowProxy, } from '../utils'; import { Extractor } from './Extractor'; @@ -31,7 +29,9 @@ export class LuluStream extends Extractor { } public override normalize(url: URL): URL { - return new URL(url.href.replace('/d/', '/e/')); + const videoId = url.pathname.split('/').slice(-1)[0] as string; + + return new URL(`/e/${videoId}`, url); } protected async extractInternal(ctx: Context, url: URL, meta: Meta): Promise { @@ -47,7 +47,7 @@ export class LuluStream extends Extractor { const $ = cheerio.load(html); const title = $('h1').text().trim(); - const sizeMatch = html.match(/([\d.]+ ?[GM]B)/) as string[]; + const heightAndSizeMatch = html.match(/\d{3,}x(\d{3,}), ([\d.]+ ?[GM]B)/) as string[]; const playlistUrl = await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'LuluStream', url, headers); @@ -60,9 +60,9 @@ export class LuluStream extends Extractor { ttl: this.ttl, meta: { ...meta, - bytes: bytes.parse(sizeMatch[1] as string) as number, - height: await guessHeightFromPlaylist(ctx, this.fetcher, playlistUrl, MEDIAFLOW_DEFAULT_INIT), title, + bytes: bytes.parse(heightAndSizeMatch[2] as string) as number, + height: parseInt(heightAndSizeMatch[1] as string), }, }, ]; diff --git a/src/extractor/__fixtures__/LuluStream/https:mediaflow.test.org-a2f2340c4a16e932bc5ea0c234dda69f b/src/extractor/__fixtures__/LuluStream/https:mediaflow.test.org-a2f2340c4a16e932bc5ea0c234dda69f deleted file mode 100644 index 16e8603..0000000 --- a/src/extractor/__fixtures__/LuluStream/https:mediaflow.test.org-a2f2340c4a16e932bc5ea0c234dda69f +++ /dev/null @@ -1,4 +0,0 @@ -#EXTM3U -#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1498884,RESOLUTION=1280x720,FRAME-RATE=24.000,CODECS="avc1.4d401f,mp4a.40.2" -https://mediaflow.test.org/proxy/hls/manifest.m3u8?api_password=test&h_user-agent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F136.0.0.0+Safari%2F537.36&h_referer=https%3A%2F%2Fstreamhihi.com%2Fe%2Fmk9m58lz8ts6&d=https%3A%2F%2Fh1gdnnp1dr11.tnmr.org%2Fhls2%2F02%2F02416%2Fqx1ysro2ny1o_h%2Findex-v1-a1.m3u8%3Ft%3DC1RS64a-9j6bSDO9TmHU9jIZpVb59jsWah7j-KgJkRg%26s%3D1759753708%26e%3D28800%26f%3D12081096%26i%3D0.3%26sp%3D0 -#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=41327,RESOLUTION=1280x720,CODECS="avc1.4d401f",URI="https://mediaflow.test.org/proxy/hls/manifest.m3u8?api_password=test&h_user-agent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F136.0.0.0+Safari%2F537.36&h_referer=https%3A%2F%2Fstreamhihi.com%2Fe%2Fmk9m58lz8ts6&d=https%3A%2F%2Fh1gdnnp1dr11.tnmr.org%2Fhls2%2F02%2F02416%2Fqx1ysro2ny1o_h%2Fiframes-v1-a1.m3u8%3Ft%3DC1RS64a-9j6bSDO9TmHU9jIZpVb59jsWah7j-KgJkRg%26s%3D1759753708%26e%3D28800%26f%3D12081096%26i%3D0.3%26sp%3D0" diff --git a/src/extractor/__snapshots__/LuluStream.test.ts.snap b/src/extractor/__snapshots__/LuluStream.test.ts.snap index f2d5c98..5c57140 100644 --- a/src/extractor/__snapshots__/LuluStream.test.ts.snap +++ b/src/extractor/__snapshots__/LuluStream.test.ts.snap @@ -2,6 +2,24 @@ exports[`LuluStream no such file 1`] = `[]`; +exports[`LuluStream streamhihi 1`] = ` +[ + { + "format": "hls", + "label": "LuluStream (via MediaFlow Proxy)", + "meta": { + "bytes": 1288490188, + "countryCodes": [], + "height": 720, + "title": "The Thursday Murder Club 2025 1080p NF WEB-DL DDP5 1 Atmos H 264-playWEB", + }, + "sourceId": "lulustream_", + "ttl": 900000, + "url": "https://mediaflow.test.org/proxy/hls/manifest.m3u8?api_password=test&h_user-agent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F136.0.0.0+Safari%2F537.36&h_referer=https%3A%2F%2Fstreamhihi.com%2Fe%2Fmk9m58lz8ts6&d=https%3A%2F%2Fh1gdnnp1dr11.tnmr.org%2Fhls2%2F02%2F02416%2Fqx1ysro2ny1o_h%2Fmaster.m3u8%3Ft%3DC1RS64a-9j6bSDO9TmHU9jIZpVb59jsWah7j-KgJkRg%26s%3D1759753708%26e%3D28800%26f%3D12081096%26i%3D0.3%26sp%3D0", + }, +] +`; + exports[`LuluStream streamhihi d 1`] = ` [ {