perf(extractor): do not guess resolution via MFP playlist for FileLions
This commit is contained in:
parent
f1c00e2684
commit
a7360b68f0
7 changed files with 177 additions and 39 deletions
|
|
@ -2,12 +2,7 @@ import bytes from 'bytes';
|
|||
import * as cheerio from 'cheerio';
|
||||
import { NotFoundError } from '../error';
|
||||
import { Context, Format, Meta, UrlResult } from '../types';
|
||||
import {
|
||||
buildMediaFlowProxyExtractorStreamUrl,
|
||||
guessHeightFromPlaylist,
|
||||
MEDIAFLOW_DEFAULT_INIT,
|
||||
supportsMediaFlowProxy,
|
||||
} from '../utils';
|
||||
import { buildMediaFlowProxyExtractorStreamUrl, supportsMediaFlowProxy, unpackEval } from '../utils';
|
||||
import { Extractor } from './Extractor';
|
||||
|
||||
/** @see https://github.com/Gujal00/ResolveURL/commits/master/script.module.resolveurl/lib/resolveurl/plugins/filelions.py */
|
||||
|
|
@ -62,39 +57,41 @@ export class FileLions extends Extractor {
|
|||
}
|
||||
|
||||
public override normalize(url: URL): URL {
|
||||
return new URL(url.href.replace('/f/', '/v/').replace('/download/', '/v/').replace('/file/', '/v/'));
|
||||
return new URL(url.href.replace('/v/', '/f/').replace('/download/', '/f/').replace('/file/', '/f/'));
|
||||
}
|
||||
|
||||
protected async extractInternal(ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> {
|
||||
const headers = { Referer: meta.referer ?? url.href };
|
||||
|
||||
const fileUrl = new URL(url.href.replace('/v/', '/f/'));
|
||||
const html = await this.fetcher.text(ctx, fileUrl, { headers });
|
||||
const html = await this.fetcher.text(ctx, url, { headers });
|
||||
|
||||
if (html.includes('This video can be watched as embed only')) {
|
||||
return await this.extractInternal(ctx, new URL(url.href.replace('/f/', '/v/')), meta);
|
||||
}
|
||||
|
||||
if (/File Not Found/.test(html)) {
|
||||
throw new NotFoundError();
|
||||
}
|
||||
|
||||
const unpacked = unpackEval(html);
|
||||
const heightMatch = unpacked.match(/(\d{3,})p/) as string[];
|
||||
|
||||
const sizeMatch = html.match(/([\d.]+ ?[GM]B)/);
|
||||
|
||||
const playlistUrl = await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'FileLions', url, headers);
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
const title = $('title').text().trim().replace(/^Watch /, '').trim();
|
||||
const title = $('meta[name="description"]').attr('content') as string;
|
||||
|
||||
return [
|
||||
{
|
||||
url: playlistUrl,
|
||||
url: await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'FileLions', url, headers),
|
||||
format: Format.hls,
|
||||
label: this.label,
|
||||
sourceId: `${this.id}_${meta.countryCodes?.join('_')}`,
|
||||
ttl: this.ttl,
|
||||
meta: {
|
||||
...meta,
|
||||
height: await guessHeightFromPlaylist(ctx, this.fetcher, playlistUrl, { ...MEDIAFLOW_DEFAULT_INIT, headers: { Referer: url.href } }),
|
||||
...(sizeMatch && {
|
||||
bytes: bytes.parse(sizeMatch[1] as string) as number,
|
||||
}),
|
||||
height: parseInt(heightMatch[1] as string),
|
||||
...(sizeMatch && { bytes: bytes.parse(sizeMatch[1] as string) as number }),
|
||||
...(title && { title }),
|
||||
},
|
||||
},
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +0,0 @@
|
|||
#EXTM3U
|
||||
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio0",NAME="Deutsch",LANGUAGE="de",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",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%2Fkinoger.com&d=https%3A%2F%2F6dkdxt1udlqhbho.ovaltinecdn.com%2Fhls2%2F01%2F01552%2Ftah5znapz3e5_n%2Findex-a1.m3u8"
|
||||
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio0",NAME="English",LANGUAGE="en",AUTOSELECT=NO,DEFAULT=NO,CHANNELS="2",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%2Fkinoger.com&d=https%3A%2F%2F6dkdxt1udlqhbho.ovaltinecdn.com%2Fhls2%2F01%2F01552%2Ftah5znapz3e5_n%2Findex-a2.m3u8"
|
||||
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2862563,RESOLUTION=1920x1080,FRAME-RATE=25.000,CODECS="avc1.640028,mp4a.40.2",VIDEO-RANGE=SDR,AUDIO="audio0"
|
||||
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%2Fkinoger.com&d=https%3A%2F%2F6dkdxt1udlqhbho.ovaltinecdn.com%2Fhls2%2F01%2F01552%2Ftah5znapz3e5_n%2Findex-v1-a1.m3u8
|
||||
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=123231,RESOLUTION=1920x1080,CODECS="avc1.640028",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%2Fkinoger.com&d=https%3A%2F%2F6dkdxt1udlqhbho.ovaltinecdn.com%2Fhls2%2F01%2F01552%2Ftah5znapz3e5_n%2Fiframes-v1-a1.m3u8",VIDEO-RANGE=SDR
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
#EXTM3U
|
||||
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1242387,RESOLUTION=1728x720,FRAME-RATE=23.974,CODECS="avc1.640020,mp4a.40.2",VIDEO-RANGE=SDR
|
||||
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%2Ffilelions.to%2Fv%2Ftyn45apubte2&d=https%3A%2F%2Frnzt2t4xvku08.acek-cdn.com%2Fhls2%2F01%2F05594%2Ftyn45apubte2_n%2Findex-v1-a1.m3u8%3Ft%3D8y6hK40boUynXnkyW5s63kFaWpt6_A5UcG5LBUX3j_4%26s%3D1756131487%26e%3D129600%26f%3D27974684%26srv%3DF6vE2P5Wjncn%26i%3D0.4%26sp%3D500%26p1%3DF6vE2P5Wjncn%26p2%3DF6vE2P5Wjncn%26asn%3D31898
|
||||
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=69531,RESOLUTION=1728x720,CODECS="avc1.640020",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%2Ffilelions.to%2Fv%2Ftyn45apubte2&d=https%3A%2F%2Frnzt2t4xvku08.acek-cdn.com%2Fhls2%2F01%2F05594%2Ftyn45apubte2_n%2Fiframes-v1-a1.m3u8%3Ft%3D8y6hK40boUynXnkyW5s63kFaWpt6_A5UcG5LBUX3j_4%26s%3D1756131487%26e%3D129600%26f%3D27974684%26srv%3DF6vE2P5Wjncn%26i%3D0.4%26sp%3D500%26p1%3DF6vE2P5Wjncn%26p2%3DF6vE2P5Wjncn%26asn%3D31898",VIDEO-RANGE=SDR
|
||||
150
src/extractor/__fixtures__/FileLions/https:mivalyo.comvtah5znapz3e5
generated
Normal file
150
src/extractor/__fixtures__/FileLions/https:mivalyo.comvtah5znapz3e5
generated
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -11,7 +11,7 @@ exports[`FileLions filelions f 1`] = `
|
|||
"bytes": 481191526,
|
||||
"countryCodes": [],
|
||||
"height": 720,
|
||||
"title": "dexter resurrection s01e01 1080p web h264 successfulcrab",
|
||||
"title": "dexter resurrection s01e01 1080p web h264-successfulcrab",
|
||||
},
|
||||
"sourceId": "filelions_",
|
||||
"ttl": 900000,
|
||||
|
|
@ -26,10 +26,11 @@ exports[`FileLions mivalyo v referer lock 1`] = `
|
|||
"format": "hls",
|
||||
"label": "FileLions (via MediaFlow Proxy)",
|
||||
"meta": {
|
||||
"bytes": 2097152,
|
||||
"countryCodes": [],
|
||||
"height": 1080,
|
||||
"referer": "https://kinoger.com",
|
||||
"title": "Versailles S01E01 German AC3 1080p BDRip x265 FuN",
|
||||
"title": "Versailles S01E01 German AC3 DL 1080p BDRip x265-FuN",
|
||||
},
|
||||
"sourceId": "filelions_",
|
||||
"ttl": 900000,
|
||||
|
|
|
|||
Loading…
Reference in a new issue