perf(extractor): do not guess resolution via MFP playlist for LuluStream

This commit is contained in:
WebStreamr 2025-10-07 13:25:18 +00:00
parent 312f60660a
commit b3db546e00
No known key found for this signature in database
4 changed files with 28 additions and 10 deletions

View file

@ -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();
});

View file

@ -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<UrlResult[]> {
@ -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),
},
},
];

View file

@ -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"

View file

@ -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`] = `
[
{