diff --git a/src/extractor/FileLions.ts b/src/extractor/FileLions.ts index 43c8a6d..a873db4 100644 --- a/src/extractor/FileLions.ts +++ b/src/extractor/FileLions.ts @@ -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 { 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 }), }, }, diff --git a/src/extractor/__fixtures__/FileLions/https:filelions.toftyn45apubte2 b/src/extractor/__fixtures__/FileLions/https:filelions.toftyn45apubte2 index 934f967..832eef9 100644 --- a/src/extractor/__fixtures__/FileLions/https:filelions.toftyn45apubte2 +++ b/src/extractor/__fixtures__/FileLions/https:filelions.toftyn45apubte2 @@ -94,7 +94,7 @@ - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/extractor/__snapshots__/FileLions.test.ts.snap b/src/extractor/__snapshots__/FileLions.test.ts.snap index 45aa269..9122b92 100644 --- a/src/extractor/__snapshots__/FileLions.test.ts.snap +++ b/src/extractor/__snapshots__/FileLions.test.ts.snap @@ -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,