chore(extractor): extract size and title for Fastream URLs

This commit is contained in:
WebStreamr 2025-08-18 12:30:28 +00:00
parent bfdb212770
commit 36f3d70467
No known key found for this signature in database
4 changed files with 250 additions and 15 deletions

View file

@ -1,5 +1,6 @@
import bytes from 'bytes';
import { Context, CountryCode, Format, UrlResult } from '../types';
import { buildMediaFlowProxyExtractorStreamUrl, Fetcher, guessHeightFromPlaylist, supportsMediaFlowProxy } from '../utils';
import { buildMediaFlowProxyExtractorStreamUrl, Fetcher, supportsMediaFlowProxy } from '../utils';
import { Extractor } from './Extractor';
export class Fastream extends Extractor {
@ -23,9 +24,19 @@ export class Fastream extends Extractor {
return null !== url.host.match(/fastream/) && supportsMediaFlowProxy(ctx);
}
public override normalize(url: URL): URL {
return new URL(url.href.replace('/e/', '/embed-').replace('/d/', '/embed-'));
}
protected async extractInternal(ctx: Context, url: URL, countryCode: CountryCode): Promise<UrlResult[]> {
const playlistUrl = await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'Fastream', url);
const downloadUrl = new URL(url.href.replace('/embed-', '/d/'));
const html = await this.fetcher.text(ctx, downloadUrl);
const heightAndSizeMatch = html.match(/\d{3,}x(\d{3,}), ([\d.]+ ?[GM]B)/) as string[];
const titleMatch = html.match(/>Download (.*?)</) as string[];
return [
{
url: playlistUrl,
@ -35,7 +46,9 @@ export class Fastream extends Extractor {
ttl: this.ttl,
meta: {
countryCodes: [countryCode],
height: await guessHeightFromPlaylist(ctx, this.fetcher, playlistUrl),
bytes: bytes.parse(heightAndSizeMatch[2] as string) as number,
height: parseInt(heightAndSizeMatch[1] as string),
title: titleMatch[1],
},
},
];

View file

@ -0,0 +1,233 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fastream</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#FFF">
<link rel="apple-touch-icon" href="https://fastream.to/images2/favicon/apple-touch-icon.png" sizes="180x180">
<link rel="icon" href="https://fastream.to/images2/favicon/favicon-32x32.png" sizes="32x32">
<link rel="icon" href="https://fastream.to/images2/favicon/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="https://fastream.to/images2/favicon/site.webmanifest" crossorigin="use-credentials">
<link rel="icon" href="https://fastream.to/images2/favicon/favicon.ico">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400..800&display=swap" rel="stylesheet">
<link href="https://fastream.to/css2/bootstrap.css?" rel="stylesheet">
<link href="https://fastream.to/css2/style.css?" rel="stylesheet">
<script src="https://fastream.to/js2/jquery.min.js?"></script>
<script src="https://fastream.to/js2/bootstrap.bundle.min.js?"></script>
<script src="https://fastream.to/js2/app.js?aс1"></script>
<script src="https://fastream.to/js2/xupload.js?aс1"></script>
</head>
<body class="">
<header class="header">
<div class="container">
<div class="row header-row align-items-center flex-nowrap">
<div class="col-auto flex-grow-1 flex-shrink-1">
<div class="row align-items-center">
<div class="col-auto d-lg-none">
<div class="dropdown">
<button class="btn icon-btn" data-bs-toggle="dropdown" data-bs-offset="0, 16">
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="22" height="16" viewBox="0 0 22 16">
<path d="M0 0h22v2H0V0zm0 7h22v2H0V7zm0 7h22v2H0v-2z"></path>
</svg>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<a href="/premium" class="dropdown-item">Premium</a>
<a href="/make_money" class="dropdown-item">Make Money</a>
<a href="/check_files" class="dropdown-item">Link Checker</a>
<a href="/api.html" class="dropdown-item">API</a>
<a href="/tos" class="dropdown-item">Terms of service</a>
<a href="/contact" class="dropdown-item">Contact Us</a>
<a href="/faq" class="dropdown-item">FAQ</a>
</ul>
</div>
</div>
<div class="col-auto me-lg-4">
<a href="/" class="logo">
<img src="https://fastream.to/images2/logo.svg?" alt="">
</a>
</div>
<div class="col-auto d-none d-lg-block">
<nav class="nav">
<a class="nav-link link-body-emphasis" href="/premium">Premium</a>
<a class="nav-link link-body-emphasis" href="/make_money">Make Money</a>
</nav>
</div>
</div>
</div>
<div class="col-auto">
<div class="dropdown header-lang">
<button type="button" class="btn icon-btn" data-bs-toggle="dropdown" data-bs-offset="0, 16">
<img src="https://fastream.to/images2/flags/english.svg" alt="">
</button>
<div class="dropdown-menu">
<a href="/?op=change_lang&lang=English" class="dropdown-item"><img src="https://fastream.to/images2/flags/english.svg" alt="">English</a>
<a href="/?op=change_lang&lang=Russian" class="dropdown-item"><img src="https://fastream.to/images2/flags/russian.svg" alt="">Russian</a>
</div>
</div>
</div>
<div class="col-auto d-none d-lg-block">
<a href="/login.html" class="btn me-2 login-btn link-body-emphasis">Login</a>
<a href="/?op=registration" class="btn btn-primary reg-btn">Sign Up</a>
</div>
<div class="col-auto d-lg-none">
<div class="dropdown">
<button class="btn icon-btn" data-bs-toggle="dropdown" data-bs-offset="0, 16">
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="22" height="22" viewBox="0 0 22 22">
<path d="M11 22C4.9 22 0 17.1 0 11S4.9 0 11 0s11 4.9 11 11-4.9 11-11 11zm0-20c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9z"></path>
<path d="M11 15.3c-3 0-5.4-2.4-5.4-5.4S8 4.4 11 4.4s5.4 2.4 5.4 5.4-2.4 5.5-5.4 5.5zm0-8.9c-1.9 0-3.4 1.5-3.4 3.4s1.5 3.4 3.4 3.4 3.4-1.5 3.4-3.4-1.5-3.4-3.4-3.4z"></path>
<path d="M4.9 19.8c-.2 0-.3 0-.5-.1-.5-.3-.6-.9-.4-1.4 1.5-2.5 3.9-3.8 7-3.8s5.5 1.3 7 3.8c.3.5.1 1.1-.3 1.4-.5.3-1.1.1-1.4-.3-1.1-1.9-2.9-2.8-5.2-2.8-2.4 0-4.1.9-5.3 2.8-.2.2-.6.4-.9.4z"></path>
</svg>
</button>
<div class="dropdown-menu dropdown-menu-end">
<a class="dropdown-item" href="/login.html">Login</a>
<a class="dropdown-item" href="/?op=registration">Sign Up</a>
<a class="dropdown-item" href="/?op=forgot_pass">Forgot your password?</a>
</div>
</div>
</div>
</div>
</div>
</header>
<main>
<table class="tbl1" >
<th colspan=2>Download black.mirror.s01e01.lat.720p.mp4</th>
<tr><td><a href="https://fastream.to/d/3aooif4ozt10_x">UHD quality</a></td><td>1920x1080, 1.0 GB</td></tr>
<tr><td><a href="https://fastream.to/d/3aooif4ozt10_h">HD quality</a></td><td>1280x720, 396.8 MB</td></tr>
<tr><td><a href="https://fastream.to/d/3aooif4ozt10_n">Normal quality</a></td><td>852x480, 210.1 MB</td></tr>
<tr><td><a href="https://fastream.to/d/3aooif4ozt10_l">Low quality</a></td><td>640x360, 104.0 MB</td></tr>
</table>
</main>
<footer class="footer">
<div class="container">
<div class="footer-main">
<div class="row justify-content-center justify-content-lg-start">
<div class="col-12 col-lg-4 col-xl-3 text-center text-lg-start">
<div class="mb-4">
<a href="https://fastream.to/" class="logo">
<img src="https://fastream.to/images2/logo-w.svg?" alt="">
</a>
</div>
<div class="mb-2 text-uppercase"><!--Share us: --></div>
<div class="mb-3">
<!--span class="me-1">
<a href="#"><img src="https://fastream.to/images2/social/fb.svg" alt=""></a>
</span>
<span class="me-1">
<a href="#"><img src="https://fastream.to/images2/social/red.svg" alt=""></a>
</span>
<span class="me-1">
<a href="#"><img src="https://fastream.to/images2/social/wha.svg" alt=""></a>
</span>
<span class="me-1">
<a href="#"><img src="https://fastream.to/images2/social/x.svg" alt=""></a>
</span>
<span class="me-1">
<a href="#"><img src="https://fastream.to/images2/social/msg.svg" alt=""></a>
</span>
<span class="me-1">
<a href="#"><img src="https://fastream.to/images2/social/in.svg" alt=""></a>
</span-->
</div>
</div>
<div class="col-lg-8 col-xl-7 d-none d-lg-block">
<div class="row">
<div class="col">
<div class="text-uppercase text-dark large">Info</div>
<div class="nav flex-column">
<a href="https://fastream.to/" class="nav-link">Home</a>
<a href="/api.html" class="nav-link">API</a>
<a href="/tos" class="nav-link">Terms of service</a>
</div>
</div>
<div class="col">
<div class="text-uppercase text-dark large">Features</div>
<div class="nav flex-column">
<a href="/premium" class="nav-link">Premium</a>
<a href="/make_money" class="nav-link">Make Money</a>
<a href="/check_files" class="nav-link">Link Checker</a>
</div>
</div>
<div class="col">
<div class="text-uppercase text-dark large">Support</div>
<div class="nav flex-column">
<a href="/contact" class="nav-link">Contact Us</a>
<a href="/faq" class="nav-link">FAQ</a>
</div>
</div>
</div>
</div>
<div class="col-xl-auto text-nowrap text-end d-none d-xl-block">
<a href="https://fastream.to/login.html" class="btn btn-light login-btn me-2">Login</a>
<a href="https://fastream.to/?op=registration" class="btn btn-primary reg-btn">Sign Up</a>
</div>
</div>
</div>
</div>
<div class="footer-bottom small">
<div class="container">
<div class="row align-items-center justify-content-between">
<div class="col-auto">
<div class="text-muted">&copy; 2024 Fastream</div>
</div>
<div class="col-auto">
</div>
</div>
</div>
</div>
</footer>
<div style ="display:none"><script id="_wau1xg">var _wau = _wau || []; _wau.push(["classic", "y7jk20u14x", "1xg"]);</script><script async src="//waust.at/c.js"></script></div>
<script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'97115f719f301903',t:'MTc1NTUxOTcwNQ=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body>
</html>

View file

@ -1,13 +0,0 @@
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=318390,RESOLUTION=640x360,FRAME-RATE=25.000,CODECS="avc1.64001e,mp4a.40.2"
https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_l%2Findex-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=648989,RESOLUTION=852x480,FRAME-RATE=25.000,CODECS="avc1.64001e,mp4a.40.2"
https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_n%2Findex-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1231528,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.64001f,mp4a.40.2"
https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_h%2Findex-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3193889,RESOLUTION=1920x1080,FRAME-RATE=25.000,CODECS="avc1.42001e,mp4a.40.2"
https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_x%2Findex-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=21129,RESOLUTION=640x360,CODECS="avc1.64001e",URI="https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_l%2Fiframes-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=37640,RESOLUTION=852x480,CODECS="avc1.64001e",URI="https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_n%2Fiframes-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=63209,RESOLUTION=1280x720,CODECS="avc1.64001f",URI="https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_h%2Fiframes-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=693070,RESOLUTION=1920x1080,CODECS="avc1.42001e",URI="https://mediaflow-proxy.test/proxy/hls/manifest.m3u8?api_password=asdfg&h_user-agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A138.0%29+Gecko%2F20100101+Firefox%2F138.0&h_Accept=%2A%2F%2A&h_Connection=keep-alive&h_Accept-Language=en-US%2Cen%3Bq%3D0.5&h_referer=https%3A%2F%2Ffastream.to%2F&h_origin=https%3A%2F%2Ffastream.to&d=https%3A%2F%2Fs28.fastream.to%2Fhls2%2F09%2F00024%2F3aooif4ozt10_x%2Fiframes-v1-a1.m3u8%3Ft%3Dnw6_aeN6pDROuXsJQwyrJVm3qHKFedVfbTNj5LgXH-4%26s%3D1752863379%26e%3D43200%26v%3D1058373%26i%3D0.3%26sp%3D0"

View file

@ -6,10 +6,12 @@ exports[`Fastream fastream.to embed 1`] = `
"format": "hls",
"label": "Fastream (via MediaFlow Proxy)",
"meta": {
"bytes": 1073741824,
"countryCodes": [
"es",
],
"height": 1080,
"title": "black.mirror.s01e01.lat.720p.mp4",
},
"sourceId": "fastream_es",
"ttl": 0,