From 8430e5d0d1ceb30d267090cc3e1409b9e9773180 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Mon, 25 Aug 2025 14:28:59 +0000 Subject: [PATCH] feat(extractor): add FileLions extractor --- src/extractor/ExtractorRegistry.ts | 2 +- src/extractor/FileLions.test.ts | 20 + src/extractor/FileLions.ts | 93 ++++ .../FileLions/https:filelions.toftyn45apubte2 | 503 ++++++++++++++++++ ....test.org-3ae485009fb31845c4840cef8ccac74b | 6 + ....test.org-efb89e5a2d68b05cdb412bff3f87e8b7 | 4 + ...ilelions.topercent2Fvpercent2Ftyn45apubte2 | 1 + ...ttpspercent3Apercent2Fpercent2Fkinoger.com | 1 + .../FileLions/https:mivalyo.comftah5znapz3e5 | 138 +++++ .../__snapshots__/FileLions.test.ts.snap | 37 ++ src/extractor/index.ts | 2 + src/types.ts | 1 + src/utils/StreamResolver.ts | 2 +- src/utils/media-flow-proxy.ts | 8 +- 14 files changed, 815 insertions(+), 3 deletions(-) create mode 100644 src/extractor/FileLions.test.ts create mode 100644 src/extractor/FileLions.ts create mode 100644 src/extractor/__fixtures__/FileLions/https:filelions.toftyn45apubte2 create mode 100644 src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-3ae485009fb31845c4840cef8ccac74b create mode 100644 src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-efb89e5a2d68b05cdb412bff3f87e8b7 create mode 100644 src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Ffilelions.topercent2Fvpercent2Ftyn45apubte2 create mode 100644 src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Fmivalyo.compercent2Fvpercent2Ftah5znapz3e5andh_refererhttpspercent3Apercent2Fpercent2Fkinoger.com create mode 100644 src/extractor/__fixtures__/FileLions/https:mivalyo.comftah5znapz3e5 create mode 100644 src/extractor/__snapshots__/FileLions.test.ts.snap diff --git a/src/extractor/ExtractorRegistry.ts b/src/extractor/ExtractorRegistry.ts index 251049e..37f9db7 100644 --- a/src/extractor/ExtractorRegistry.ts +++ b/src/extractor/ExtractorRegistry.ts @@ -54,7 +54,7 @@ export class ExtractorRegistry { this.logger.info(`Extract stream URL using ${extractor.id} extractor from ${url}`, ctx); - const urlResults = await extractor.extract(ctx, normalizedUrl, meta || { countryCodes: [] }); + const urlResults = await extractor.extract(ctx, normalizedUrl, { ...meta, countryCodes: meta?.countryCodes ?? [] }); if (!urlResults.some(urlResult => urlResult.error) && extractor.ttl) { await this.urlResultCache.set(cacheKey, urlResults, extractor.ttl); diff --git a/src/extractor/FileLions.test.ts b/src/extractor/FileLions.test.ts new file mode 100644 index 0000000..824aef6 --- /dev/null +++ b/src/extractor/FileLions.test.ts @@ -0,0 +1,20 @@ +import winston from 'winston'; +import { createTestContext } from '../test'; +import { FetcherMock } from '../utils'; +import { ExtractorRegistry } from './ExtractorRegistry'; +import { FileLions } from './FileLions'; + +const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] }); +const extractorRegistry = new ExtractorRegistry(logger, [new FileLions(new FetcherMock(`${__dirname}/__fixtures__/FileLions`))]); + +const ctx = createTestContext({ mediaFlowProxyUrl: 'https://mediaflow.test.org', mediaFlowProxyPassword: 'test' }); + +describe('FileLions', () => { + test('filelions f', async () => { + expect(await extractorRegistry.handle(ctx, new URL('https://filelions.to/f/tyn45apubte2'))).toMatchSnapshot(); + }); + + test('mivalyo v referer lock', async () => { + expect(await extractorRegistry.handle(ctx, new URL('https://mivalyo.com/v/tah5znapz3e5'), { referer: 'https://kinoger.com' })).toMatchSnapshot(); + }); +}); diff --git a/src/extractor/FileLions.ts b/src/extractor/FileLions.ts new file mode 100644 index 0000000..12a6654 --- /dev/null +++ b/src/extractor/FileLions.ts @@ -0,0 +1,93 @@ +import bytes from 'bytes'; +import * as cheerio from 'cheerio'; +import { Context, Format, Meta, UrlResult } from '../types'; +import { buildMediaFlowProxyExtractorStreamUrl, guessHeightFromPlaylist, supportsMediaFlowProxy } from '../utils'; +import { Extractor } from './Extractor'; + +/** @see https://github.com/Gujal00/ResolveURL/commits/master/script.module.resolveurl/lib/resolveurl/plugins/filelions.py */ +export class FileLions extends Extractor { + public readonly id = 'filelions'; + + public readonly label = 'FileLions (via MediaFlow Proxy)'; + + public override readonly ttl = 0; + + public override viaMediaFlowProxy = true; + + public supports(ctx: Context, url: URL): boolean { + const supportedDomain = null !== url.host.match(/.*lions?/) + || [ + '6sfkrspw4u.sbs', + 'ajmidyadfihayh.sbs', + 'alhayabambi.sbs', + 'anime7u.com', + 'azipcdn.com', + 'coolciima.online', + 'dhtpre.com', + 'e4xb5c2xnz.sbs', + 'egsyxutd.sbs', + 'fdewsdc.sbs', + 'gsfomqu.sbs', + 'javplaya.com', + 'katomen.online', + 'kinoger.be', + 'lumiawatch.top', + 'mivalyo.com', + 'moflix-stream.click', + 'motvy55.store', + 'movearnpre.com', + 'peytonepre.com', + 'ryderjet.com', + 'smoothpre.com', + 'taylorplayer.com', + 'techradar.ink', + 'videoland.sbs', + 'vidhide.com', + 'vidhide.fun', + 'vidhidefast.com', + 'vidhidehub.com', + 'vidhideplus.com', + 'vidhidepre.com', + 'vidhidepro.com', + 'vidhidevip.com', + ].includes(url.host); + + return supportedDomain && supportsMediaFlowProxy(ctx); + } + + public override normalize(url: URL): URL { + return new URL(url.href.replace('/f/', '/v/').replace('/download/', '/v/').replace('/file/', '/v/')); + } + + protected async extractInternal(ctx: Context, url: URL, meta: Meta): Promise { + const headers = { ...(meta.referer && { Referer: meta.referer }) }; + + const playlistUrl = await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'FileLions', url, headers); + + const fileUrl = new URL(url.href.replace('/v/', '/f/')); + const html = await this.fetcher.text(ctx, fileUrl, { headers }); + + const sizeMatch = html.match(/([\d.]+ ?[GM]B)/); + + const $ = cheerio.load(html); + const title = $('title').text().trim().replace(/^Watch /, '').trim(); + + return [ + { + url: playlistUrl, + format: Format.hls, + label: this.label, + sourceId: `${this.id}_${meta.countryCodes?.join('_')}`, + ttl: this.ttl, + meta: { + ...meta, + height: await guessHeightFromPlaylist(ctx, this.fetcher, playlistUrl), + ...(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 new file mode 100644 index 0000000..934f967 --- /dev/null +++ b/src/extractor/__fixtures__/FileLions/https:filelions.toftyn45apubte2 @@ -0,0 +1,503 @@ + + + + + + + + Watch dexter resurrection s01e01 1080p web h264 successfulcrab + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + +
+
+
+ + +
+
+
+
+ + + + + + + +
+ + + + + + +
+ + + +
+ + + + + +
+ + + + + + + +
+ +
+
+
+ +
+

+ dexter resurrection s01e01 1080p web h264-successfulcrab +

+
+ + on + Jul 11, 2025 + + + + 151 views + +
+
+
+ +
+
+
+
+
+ + +
+
+
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + +
+

+ + +
+
+ +
+ + + + + +
+ +
+
+ +
+
+
Embed size: x
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + +
+
+
+
+
+ + +
+ +
+
+

+ © 2025 Earnvids. All rights reserved. +

+
+
+
+
+
+ + + + diff --git a/src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-3ae485009fb31845c4840cef8ccac74b b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-3ae485009fb31845c4840cef8ccac74b new file mode 100644 index 0000000..2fc92b1 --- /dev/null +++ b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-3ae485009fb31845c4840cef8ccac74b @@ -0,0 +1,6 @@ +#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 diff --git a/src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-efb89e5a2d68b05cdb412bff3f87e8b7 b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-efb89e5a2d68b05cdb412bff3f87e8b7 new file mode 100644 index 0000000..9900dec --- /dev/null +++ b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.org-efb89e5a2d68b05cdb412bff3f87e8b7 @@ -0,0 +1,4 @@ +#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 diff --git a/src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Ffilelions.topercent2Fvpercent2Ftyn45apubte2 b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Ffilelions.topercent2Fvpercent2Ftyn45apubte2 new file mode 100644 index 0000000..3680c92 --- /dev/null +++ b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Ffilelions.topercent2Fvpercent2Ftyn45apubte2 @@ -0,0 +1 @@ +{"destination_url":"https://RNzT2t4XVKU08.acek-cdn.com/hls2/01/05594/tyn45apubte2_n/master.m3u8?t=8y6hK40boUynXnkyW5s63kFaWpt6_A5UcG5LBUX3j_4&s=1756131487&e=129600&f=27974684&srv=F6vE2P5Wjncn&i=0.4&sp=500&p1=F6vE2P5Wjncn&p2=F6vE2P5Wjncn&asn=31898","request_headers":{"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36","referer":"https://filelions.to/v/tyn45apubte2"},"mediaflow_proxy_url":"https://mediaflow.test.org/proxy/hls/manifest.m3u8","query_params":{"api_password":"test"}} diff --git a/src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Fmivalyo.compercent2Fvpercent2Ftah5znapz3e5andh_refererhttpspercent3Apercent2Fpercent2Fkinoger.com b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Fmivalyo.compercent2Fvpercent2Ftah5znapz3e5andh_refererhttpspercent3Apercent2Fpercent2Fkinoger.com new file mode 100644 index 0000000..0b84be5 --- /dev/null +++ b/src/extractor/__fixtures__/FileLions/https:mediaflow.test.orgextractorvideohostFileLionsandapi_passwordtestanddhttpspercent3Apercent2Fpercent2Fmivalyo.compercent2Fvpercent2Ftah5znapz3e5andh_refererhttpspercent3Apercent2Fpercent2Fkinoger.com @@ -0,0 +1 @@ +{"destination_url":"https://6dkDxt1udLQhbho.ovaltinecdn.com/hls2/01/01552/tah5znapz3e5_n/master.m3u8?t=MnSHt6lZx3bdKvTdoU1JsTLWp56dlRDLwze5Prnefew&s=1756131487&e=129600&f=7760835&srv=GOweneve6B0I&i=0.4&sp=500&p1=GOweneve6B0I&p2=GOweneve6B0I&asn=31898","request_headers":{"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36","referer":"https://kinoger.com"},"mediaflow_proxy_url":"https://mediaflow.test.org/proxy/hls/manifest.m3u8","query_params":{"api_password":"test"}} diff --git a/src/extractor/__fixtures__/FileLions/https:mivalyo.comftah5znapz3e5 b/src/extractor/__fixtures__/FileLions/https:mivalyo.comftah5znapz3e5 new file mode 100644 index 0000000..bfdfb5b --- /dev/null +++ b/src/extractor/__fixtures__/FileLions/https:mivalyo.comftah5znapz3e5 @@ -0,0 +1,138 @@ + + + + + + + + Watch Versailles S01E01 German AC3 1080p BDRip x265 FuN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + +
+
+
+ + +
+
+
+ +
+ This video can be watched as embed only +
+ + +
+
+
+
+
+
+
+ + +
+ +
+
+

+ +

+
+
+
+
+
+ + + + + diff --git a/src/extractor/__snapshots__/FileLions.test.ts.snap b/src/extractor/__snapshots__/FileLions.test.ts.snap new file mode 100644 index 0000000..941604e --- /dev/null +++ b/src/extractor/__snapshots__/FileLions.test.ts.snap @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`FileLions filelions f 1`] = ` +[ + { + "format": "hls", + "label": "FileLions (via MediaFlow Proxy)", + "meta": { + "bytes": 481191526, + "countryCodes": [], + "height": 720, + "title": "dexter resurrection s01e01 1080p web h264 successfulcrab", + }, + "sourceId": "filelions_", + "ttl": 0, + "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%2Ffilelions.to%2Fv%2Ftyn45apubte2&d=https%3A%2F%2FRNzT2t4XVKU08.acek-cdn.com%2Fhls2%2F01%2F05594%2Ftyn45apubte2_n%2Fmaster.m3u8%3Ft%3D8y6hK40boUynXnkyW5s63kFaWpt6_A5UcG5LBUX3j_4%26s%3D1756131487%26e%3D129600%26f%3D27974684%26srv%3DF6vE2P5Wjncn%26i%3D0.4%26sp%3D500%26p1%3DF6vE2P5Wjncn%26p2%3DF6vE2P5Wjncn%26asn%3D31898", + }, +] +`; + +exports[`FileLions mivalyo v referer lock 1`] = ` +[ + { + "format": "hls", + "label": "FileLions (via MediaFlow Proxy)", + "meta": { + "countryCodes": [], + "height": 1080, + "referer": "https://kinoger.com", + "title": "Versailles S01E01 German AC3 1080p BDRip x265 FuN", + }, + "sourceId": "filelions_", + "ttl": 0, + "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%2Fkinoger.com&d=https%3A%2F%2F6dkDxt1udLQhbho.ovaltinecdn.com%2Fhls2%2F01%2F01552%2Ftah5znapz3e5_n%2Fmaster.m3u8%3Ft%3DMnSHt6lZx3bdKvTdoU1JsTLWp56dlRDLwze5Prnefew%26s%3D1756131487%26e%3D129600%26f%3D7760835%26srv%3DGOweneve6B0I%26i%3D0.4%26sp%3D500%26p1%3DGOweneve6B0I%26p2%3DGOweneve6B0I%26asn%3D31898", + }, +] +`; diff --git a/src/extractor/index.ts b/src/extractor/index.ts index 0a8b241..349b954 100644 --- a/src/extractor/index.ts +++ b/src/extractor/index.ts @@ -4,6 +4,7 @@ import { Dropload } from './Dropload'; import { ExternalUrl } from './ExternalUrl'; import { Extractor } from './Extractor'; import { Fastream } from './Fastream'; +import { FileLions } from './FileLions'; import { HubCloud } from './HubCloud'; import { KinoGer } from './KinoGer'; import { Mixdrop } from './Mixdrop'; @@ -25,6 +26,7 @@ export const createExtractors = (fetcher: Fetcher): Extractor[] => [ new DoodStream(fetcher), new Dropload(fetcher), new Fastream(fetcher), + new FileLions(fetcher), new HubCloud(fetcher), new KinoGer(fetcher), new Mixdrop(fetcher), diff --git a/src/types.ts b/src/types.ts index 3a3de60..ab7866e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -70,6 +70,7 @@ export interface Meta { bytes?: number | undefined; countryCodes?: CountryCode[]; height?: number | undefined; + referer?: string | undefined; title?: string | undefined; } diff --git a/src/utils/StreamResolver.ts b/src/utils/StreamResolver.ts index 2e91f4c..98bdc5e 100644 --- a/src/utils/StreamResolver.ts +++ b/src/utils/StreamResolver.ts @@ -51,7 +51,7 @@ export class StreamResolver { this.logger.info(`${source.id} returned ${sourceResults.length} urls`, ctx); const sourceUrlResults = await Promise.all( - sourceResults.map(({ url, meta }) => this.extractorRegistry.handle(ctx, url, meta)), + sourceResults.map(({ url, meta }) => this.extractorRegistry.handle(ctx, url, { ...meta, referer: source.baseUrl })), ); urlResults.push(...sourceUrlResults.flat()); diff --git a/src/utils/media-flow-proxy.ts b/src/utils/media-flow-proxy.ts index e4498e9..bedc70c 100644 --- a/src/utils/media-flow-proxy.ts +++ b/src/utils/media-flow-proxy.ts @@ -28,8 +28,11 @@ export const buildMediaFlowProxyExtractorRedirectUrl = (ctx: Context, host: stri return mediaFlowProxyUrl; }; -export const buildMediaFlowProxyExtractorStreamUrl = async (ctx: Context, fetcher: Fetcher, host: string, url: URL): Promise => { +export const buildMediaFlowProxyExtractorStreamUrl = async (ctx: Context, fetcher: Fetcher, host: string, url: URL, headers: Record = {}): Promise => { const mediaFlowProxyUrl = buildMediaFlowProxyExtractorUrl(ctx, host, url); + for (const headerKey in headers) { + mediaFlowProxyUrl.searchParams.set('h_' + headerKey.toLowerCase(), headers[headerKey] as string); + } const extractResult: ExtractResult = JSON.parse(await fetcher.text(ctx, mediaFlowProxyUrl)); @@ -41,6 +44,9 @@ export const buildMediaFlowProxyExtractorStreamUrl = async (ctx: Context, fetche for (const requestHeadersKey in extractResult.request_headers) { streamUrl.searchParams.append(`h_${requestHeadersKey}`, extractResult.request_headers[requestHeadersKey] as string); } + for (const headerKey in headers) { + streamUrl.searchParams.set('h_' + headerKey.toLowerCase(), headers[headerKey] as string); + } streamUrl.searchParams.append('d', extractResult.destination_url); return streamUrl;