From e11cf8986ed0e33d2032624ccee9b15539ed3317 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:01:58 +0000 Subject: [PATCH] perf(extractor): do not guess size from mp4 for Streamtape --- src/extractor/Streamtape.ts | 17 +- ....test.org-f07f944d9efd780e6bb41b27f95c2308 | 1 - ...HkJ7zWALL-E.2008.1080p.BrRip.x264.YIFY.mp4 | 32 +- ...HkJ7zWALL-E.2008.1080p.BrRip.x264.YIFY.mp4 | 331 ++++++++++++++++++ .../__snapshots__/Streamtape.test.ts.snap | 4 +- 5 files changed, 359 insertions(+), 26 deletions(-) delete mode 100644 src/extractor/__fixtures__/Streamtape/head-https:mediaflow.test.org-f07f944d9efd780e6bb41b27f95c2308 create mode 100644 src/extractor/__fixtures__/Streamtape/https:streamtape.comvDjmZBG0K9gHkJ7zWALL-E.2008.1080p.BrRip.x264.YIFY.mp4 diff --git a/src/extractor/Streamtape.ts b/src/extractor/Streamtape.ts index 6415054..c8994d6 100644 --- a/src/extractor/Streamtape.ts +++ b/src/extractor/Streamtape.ts @@ -1,10 +1,10 @@ +import bytes from 'bytes'; import * as cheerio from 'cheerio'; import { Context, Format, Meta, UrlResult } from '../types'; import { - buildMediaFlowProxyExtractorRedirectUrl, MEDIAFLOW_DEFAULT_INIT, + buildMediaFlowProxyExtractorRedirectUrl, supportsMediaFlowProxy, } from '../utils'; -import { guessSizeFromMp4 } from '../utils/size'; import { Extractor } from './Extractor'; export class Streamtape extends Extractor { @@ -17,22 +17,25 @@ export class Streamtape extends Extractor { } public override normalize(url: URL): URL { - return new URL(url.href.replace('/v/', '/e/')); + return new URL(url.href.replace('/e/', '/v/')); } protected async extractInternal(ctx: Context, url: URL, meta: Meta): Promise { const headers = { Referer: meta.referer ?? url.href }; + // Only needed to properly find non-existing files via 404 response + await this.fetcher.text(ctx, new URL(url.href.replace('/v/', '/e/')), { headers }); + const html = await this.fetcher.text(ctx, url, { headers }); + const sizeMatch = html.match(/([\d.]+ ?[GM]B)/) as string[]; + const $ = cheerio.load(html); const title = $('meta[name="og:title"]').attr('content') as string; - const mp4Url = buildMediaFlowProxyExtractorRedirectUrl(ctx, 'Streamtape', url, headers); - return [ { - url: mp4Url, + url: buildMediaFlowProxyExtractorRedirectUrl(ctx, 'Streamtape', url, headers), format: Format.mp4, label: this.label, sourceId: `${this.id}_${meta.countryCodes?.join('_')}`, @@ -40,7 +43,7 @@ export class Streamtape extends Extractor { meta: { ...meta, title, - bytes: await guessSizeFromMp4(ctx, this.fetcher, mp4Url, MEDIAFLOW_DEFAULT_INIT), + bytes: bytes.parse(sizeMatch[1] as string) as number, }, }, ]; diff --git a/src/extractor/__fixtures__/Streamtape/head-https:mediaflow.test.org-f07f944d9efd780e6bb41b27f95c2308 b/src/extractor/__fixtures__/Streamtape/head-https:mediaflow.test.org-f07f944d9efd780e6bb41b27f95c2308 deleted file mode 100644 index 8ddb72e..0000000 --- a/src/extractor/__fixtures__/Streamtape/head-https:mediaflow.test.org-f07f944d9efd780e6bb41b27f95c2308 +++ /dev/null @@ -1 +0,0 @@ -{"connection":"close","content-length":"1293552945","content-range":"bytes 0-1293552944/1293552945","content-type":"video/mp4","date":"Thu, 25 Sep 2025 19:52:25 GMT","etag":"\"6878008a-4d1a0d31\"","last-modified":"Wed, 16 Jul 2025 19:42:02 GMT","server":"nginx/1.24.0 (Ubuntu)"} \ No newline at end of file diff --git a/src/extractor/__fixtures__/Streamtape/https:streamtape.comeDjmZBG0K9gHkJ7zWALL-E.2008.1080p.BrRip.x264.YIFY.mp4 b/src/extractor/__fixtures__/Streamtape/https:streamtape.comeDjmZBG0K9gHkJ7zWALL-E.2008.1080p.BrRip.x264.YIFY.mp4 index 3c8e70a..4fd9ca0 100644 --- a/src/extractor/__fixtures__/Streamtape/https:streamtape.comeDjmZBG0K9gHkJ7zWALL-E.2008.1080p.BrRip.x264.YIFY.mp4 +++ b/src/extractor/__fixtures__/Streamtape/https:streamtape.comeDjmZBG0K9gHkJ7zWALL-E.2008.1080p.BrRip.x264.YIFY.mp4 @@ -155,40 +155,40 @@ try{count++;if(loop && !did && count < 100) setTimeout(function(){adblock(loop); } adblock(true); document.addEventListener("readystatechange", function(){adblock();}); -window.WJSzQHSJRp=adblock; +window.wtwFEMpFcN=adblock; })(); - +
-
- - - - @@ -232,7 +232,7 @@ document.getElementById('robotlink').innerHTML = '//streamtape.com/get_video?id= + + + +
+ +
+
+
+
+
+

WALL-E.2008.1080p.BrRip.x264.YIFY.mp4

+
+ +
ad
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + +
+
+
+ Turn off the lights +
+ +
+
+
+
+ +
+
+ +
+
+

1.20 GB

+
+
+
+
+

Embed this video:

+ +
+ + +
+ +
+
+
+
+ + + + + + + + + + + + + + diff --git a/src/extractor/__snapshots__/Streamtape.test.ts.snap b/src/extractor/__snapshots__/Streamtape.test.ts.snap index ab5a797..0fe206d 100644 --- a/src/extractor/__snapshots__/Streamtape.test.ts.snap +++ b/src/extractor/__snapshots__/Streamtape.test.ts.snap @@ -6,13 +6,13 @@ exports[`Streamtape streamtape.com /e 1`] = ` "format": "mp4", "label": "Streamtape (via MediaFlow Proxy)", "meta": { - "bytes": 1293552945, + "bytes": 1288490188, "countryCodes": [], "title": "WALL-E.2008.1080p.BrRip.x264.YIFY.mp4", }, "sourceId": "streamtape_", "ttl": 900000, - "url": "https://mediaflow.test.org/extractor/video?host=Streamtape&api_password=test&d=https%3A%2F%2Fstreamtape.com%2Fe%2FDjmZBG0K9gHkJ7z%2FWALL-E.2008.1080p.BrRip.x264.YIFY.mp4&h_referer=https%3A%2F%2Fstreamtape.com%2Fe%2FDjmZBG0K9gHkJ7z%2FWALL-E.2008.1080p.BrRip.x264.YIFY.mp4&redirect_stream=true", + "url": "https://mediaflow.test.org/extractor/video?host=Streamtape&api_password=test&d=https%3A%2F%2Fstreamtape.com%2Fv%2FDjmZBG0K9gHkJ7z%2FWALL-E.2008.1080p.BrRip.x264.YIFY.mp4&h_referer=https%3A%2F%2Fstreamtape.com%2Fv%2FDjmZBG0K9gHkJ7z%2FWALL-E.2008.1080p.BrRip.x264.YIFY.mp4&redirect_stream=true", }, ] `;