From b940df5bc095ed9c5537271321abfcd360909531 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:17:06 +0000 Subject: [PATCH] chore(extractor): add DoodStream height guessing based on title --- src/extractor/DoodStream.ts | 4 +++- src/handler/__snapshots__/Frembed.test.ts.snap | 2 ++ src/utils/height.ts | 8 ++++++++ src/utils/index.ts | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/utils/height.ts diff --git a/src/extractor/DoodStream.ts b/src/extractor/DoodStream.ts index 94bc770..75ad271 100644 --- a/src/extractor/DoodStream.ts +++ b/src/extractor/DoodStream.ts @@ -1,7 +1,7 @@ import randomstring from 'randomstring'; import * as cheerio from 'cheerio'; import { Extractor } from './types'; -import { Fetcher } from '../utils'; +import { Fetcher, guessFromTitle } from '../utils'; import { Context, Meta, UrlResult } from '../types'; import { NotFoundError } from '../error'; @@ -40,6 +40,7 @@ export class DoodStream implements Extractor { const $ = cheerio.load(html); const title = $('title').text().trim().replace(/ - DoodStream$/, '').trim(); + const height = guessFromTitle(title); const mp4Url = new URL(`${baseUrl}${randomstring.generate(10)}?token=${token}&expiry=${Date.now()}`); @@ -55,6 +56,7 @@ export class DoodStream implements Extractor { ...meta, title, ...(mp4Head['content-length'] && { bytes: parseInt(mp4Head['content-length'] as string) }), + ...(height && { height }), }, requestHeaders: { Referer: 'http://dood.to/', diff --git a/src/handler/__snapshots__/Frembed.test.ts.snap b/src/handler/__snapshots__/Frembed.test.ts.snap index 39b13e2..fe3f563 100644 --- a/src/handler/__snapshots__/Frembed.test.ts.snap +++ b/src/handler/__snapshots__/Frembed.test.ts.snap @@ -7,6 +7,7 @@ exports[`Frembed handle imdb black mirror s4e2 1`] = ` "label": "DoodStream", "meta": { "countryCode": "fr", + "height": 720, "title": "Black Mirror S04E02 FRENCH 720p WEB x264-RiPiT", }, "requestHeaders": { @@ -66,6 +67,7 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = ` "label": "DoodStream", "meta": { "countryCode": "fr", + "height": 720, "title": "Black Mirror S04E02 FRENCH 720p WEB x264-RiPiT", }, "requestHeaders": { diff --git a/src/utils/height.ts b/src/utils/height.ts new file mode 100644 index 0000000..23ea291 --- /dev/null +++ b/src/utils/height.ts @@ -0,0 +1,8 @@ +export const guessFromTitle = (title: string): number | undefined => { + const heightMatch = title.match(/([0-9]+)p/); + if (heightMatch && heightMatch[1]) { + return parseInt(heightMatch[1]); + } + + return undefined; +}; diff --git a/src/utils/index.ts b/src/utils/index.ts index db2d57c..688bd8a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -3,6 +3,7 @@ export * from './StreamResolver'; export * from './config'; export * from './embed'; export * from './env'; +export * from './height'; export * from './id'; export * from './language'; export * from './manifest';