refactor(extractor): manipulate URL instead of creating new one

This commit is contained in:
WebStreamr 2025-05-18 21:48:17 +02:00
parent fb61d39225
commit b5c45d806e
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -19,8 +19,8 @@ export class Dropload implements Extractor {
readonly supports = (url: URL): boolean => null !== url.host.match(/dropload/);
readonly extract = async (ctx: Context, url: URL, countryCode: string) => {
const normalizedUrl = url.href.replace('/e/', '').replace('/embed-', '/');
const html = await this.fetcher.text(ctx, new URL(normalizedUrl));
url.pathname = url.pathname.replace('/e/', '').replace('/embed-', '/');
const html = await this.fetcher.text(ctx, url);
const heightMatch = html.match(/\d{3,}x(\d{3,}),/) as string[];

View file

@ -19,8 +19,8 @@ export class SuperVideo implements Extractor {
readonly supports = (url: URL): boolean => null !== url.host.match(/supervideo/);
readonly extract = async (ctx: Context, url: URL, countryCode: string) => {
const normalizedUrl = url.href.replace('/e/', '/').replace('/embed-', '/');
const html = await this.fetcher.text(ctx, new URL(normalizedUrl));
url.pathname = url.pathname.replace('/e/', '').replace('/embed-', '/');
const html = await this.fetcher.text(ctx, url);
const heightAndSizeMatch = html.match(/\d{3,}x(\d{3,}), ([\d.]+ ?[GM]B)/) as string[];