fix(extractor): handle StreamEmbed video is not ready

This commit is contained in:
WebStreamr 2025-10-06 12:55:48 +00:00
parent bb21bbc7fa
commit 424c2fd1e0
No known key found for this signature in database
4 changed files with 12 additions and 0 deletions

View file

@ -13,4 +13,8 @@ describe('StreamEmbed', () => {
test('watch.gxplayer.xyz', async () => {
expect(await extractorRegistry.handle(ctx, new URL('https://watch.gxplayer.xyz/watch?v=MEKI92PU'))).toMatchSnapshot();
});
test('video is not ready', async () => {
expect(await extractorRegistry.handle(ctx, new URL('https://watch.gxplayer.xyz/watch?v=PBO90WAS'))).toMatchSnapshot();
});
});

View file

@ -1,3 +1,4 @@
import { NotFoundError } from '../error';
import { Context, Format, Meta, UrlResult } from '../types';
import { Extractor } from './Extractor';
@ -15,6 +16,10 @@ export class StreamEmbed extends Extractor {
const html = await this.fetcher.text(ctx, url, { headers });
if (/Video is not ready/.test(html)) {
throw new NotFoundError();
}
const video = JSON.parse((html.match(/video ?= ?(.*);/) as string[])[1] as string);
return [

View file

@ -0,0 +1 @@
<html lang="en"><link type="text/css" rel="stylesheet" id="dark-mode-custom-link"><link type="text/css" rel="stylesheet" id="dark-mode-general-link"><style lang="en" type="text/css" id="dark-mode-custom-style"></style><style lang="en" type="text/css" id="dark-mode-native-style"></style><head><meta charset="utf-8"><title>Warning</title><style>body,html{width:100%;height:100%;margin:0;padding:0;background-color:#151515;overflow:hidden}body{text-align:center;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;color:#fff}#horizon{display:table;height:100%;position:static;width:100%}#sun{display:table-cell;vertical-align:middle;position:static;margin:0 auto}a,h1,p{margin:0 auto;max-width:80%}h1,p{display:block}h1{font-size:48px;margin-bottom:5px}p{font-size:24px;max-width:475px}a{color:#4bf;text-decoration:none}a[role=button]{margin-top:15px;display:inline-block;color:#fff;font-weight:700;padding:10px 20px;border-radius:5px;background:#4bf;text-shadow:none;font-size:16px}a[role=button]:active{background:#3795cc}.smaller p{font-size:18px}.smaller h1{font-size:42px}@media (max-width:499px){p{font-size:16px;line-height:1.4;max-width:290px}a[role=button]{font-size:16px;padding:7px 15px}.smaller p{font-size:15px}.smaller a[role=button]{font-size:14px}.smaller h1{font-size:36px}}@media (max-width:300px){h1{font-size:36px}p{font-size:14px;line-height:1.4;max-width:250px}a[role=button]{margin-top:10px;font-size:14px}.smaller p{font-size:12px}.smaller a[role=button]{font-size:12px}.smaller h1{font-size:28px}}</style> </head><body><div id="horizon"><div id="sun"><h1>Warning</h1><p>Video is not ready.</p> </div></div></body></html>

View file

@ -1,5 +1,7 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`StreamEmbed video is not ready 1`] = `[]`;
exports[`StreamEmbed watch.gxplayer.xyz 1`] = `
[
{