diff --git a/src/extractor/DoodStream.ts b/src/extractor/DoodStream.ts index 797785e..5c4f7c7 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 './Extractor'; -import { Fetcher, guessHeightFromTitle } from '../utils'; +import { Fetcher } from '../utils'; import { Context, CountryCode, Format, UrlResult } from '../types'; import { NotFoundError } from '../error'; @@ -57,7 +57,6 @@ export class DoodStream extends Extractor { ttl: this.ttl, meta: { countryCodes: [countryCode], - height: guessHeightFromTitle(title), title, ...(mp4Head['content-length'] && { bytes: parseInt(mp4Head['content-length'] as string) }), }, diff --git a/src/extractor/Extractor.ts b/src/extractor/Extractor.ts index d558bc1..5e89ce2 100644 --- a/src/extractor/Extractor.ts +++ b/src/extractor/Extractor.ts @@ -1,5 +1,6 @@ import { Context, CountryCode, Format, UrlResult } from '../types'; import { NotFoundError } from '../error'; +import { guessHeightFromTitle } from '../utils'; export abstract class Extractor { public abstract readonly id: string; @@ -20,7 +21,17 @@ export abstract class Extractor { public async extract(ctx: Context, url: URL, countryCode: CountryCode, title?: string | undefined): Promise { try { - return await this.extractInternal(ctx, url, countryCode, title); + const urlResults = await this.extractInternal(ctx, url, countryCode, title); + + return urlResults.map((urlResult) => { + let height = urlResult.meta.height; + + if (!height && urlResult.meta.title) { + height = guessHeightFromTitle(urlResult.meta.title); + } + + return { ...urlResult, meta: { ...urlResult.meta, height } }; + }); } catch (error) { if (error instanceof NotFoundError) { return []; diff --git a/src/extractor/KinoGer.ts b/src/extractor/KinoGer.ts index e7236e0..f60e149 100644 --- a/src/extractor/KinoGer.ts +++ b/src/extractor/KinoGer.ts @@ -1,6 +1,6 @@ import crypto from 'crypto'; import { Extractor } from './Extractor'; -import { Fetcher, guessHeightFromTitle } from '../utils'; +import { Fetcher } from '../utils'; import { Context, CountryCode, Format, UrlResult } from '../types'; /** @see https://github.com/Gujal00/ResolveURL/blob/master/script.module.resolveurl/lib/resolveurl/plugins/kinoger.py */ @@ -45,7 +45,6 @@ export class KinoGer extends Extractor { ttl: this.ttl, meta: { countryCodes: [countryCode], - height: guessHeightFromTitle(title), title, }, requestHeaders: { diff --git a/src/extractor/Mixdrop.ts b/src/extractor/Mixdrop.ts index 2c417ce..6179a97 100644 --- a/src/extractor/Mixdrop.ts +++ b/src/extractor/Mixdrop.ts @@ -1,7 +1,7 @@ import bytes from 'bytes'; import * as cheerio from 'cheerio'; import { Extractor } from './Extractor'; -import { buildMediaFlowProxyExtractorRedirectUrl, Fetcher, guessHeightFromTitle, supportsMediaFlowProxy } from '../utils'; +import { buildMediaFlowProxyExtractorRedirectUrl, Fetcher, supportsMediaFlowProxy } from '../utils'; import { Context, CountryCode, Format, UrlResult } from '../types'; import { NotFoundError } from '../error'; @@ -48,7 +48,6 @@ export class Mixdrop extends Extractor { ttl: this.ttl, meta: { countryCodes: [countryCode], - height: guessHeightFromTitle(title), title, ...(sizeMatch && { bytes: bytes.parse((sizeMatch[1] as string).replace(',', '')) as number, diff --git a/src/extractor/Streamtape.ts b/src/extractor/Streamtape.ts index 575457c..7489a83 100644 --- a/src/extractor/Streamtape.ts +++ b/src/extractor/Streamtape.ts @@ -3,7 +3,6 @@ import { Extractor } from './Extractor'; import { buildMediaFlowProxyExtractorRedirectUrl, Fetcher, - guessHeightFromTitle, supportsMediaFlowProxy, } from '../utils'; import { Context, CountryCode, Format, UrlResult } from '../types'; @@ -42,7 +41,6 @@ export class Streamtape extends Extractor { ttl: this.ttl, meta: { countryCodes: [countryCode], - height: guessHeightFromTitle(title), title, }, }, diff --git a/src/extractor/__snapshots__/ExternalUrl.test.ts.snap b/src/extractor/__snapshots__/ExternalUrl.test.ts.snap index 5c841d7..2a3cc89 100644 --- a/src/extractor/__snapshots__/ExternalUrl.test.ts.snap +++ b/src/extractor/__snapshots__/ExternalUrl.test.ts.snap @@ -12,6 +12,7 @@ exports[`ExternalUrl johnalwayssame.com with title 1`] = ` "countryCodes": [ "fr", ], + "height": undefined, "title": "Black Mirror 4x2", }, "sourceId": "external_fr", @@ -31,6 +32,7 @@ exports[`ExternalUrl netu.fanstream.us 1`] = ` "countryCodes": [ "fr", ], + "height": undefined, "title": undefined, }, "sourceId": "external_fr", diff --git a/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap b/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap index de7fc9a..cf4c565 100644 --- a/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap +++ b/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap @@ -12,6 +12,7 @@ exports[`ExtractorRegistry returns external URLs if enabled by config 1`] = ` "countryCodes": [ "de", ], + "height": undefined, "title": undefined, }, "sourceId": "external_de", diff --git a/src/extractor/__snapshots__/SuperVideo.test.ts.snap b/src/extractor/__snapshots__/SuperVideo.test.ts.snap index f95dbad..010ebec 100644 --- a/src/extractor/__snapshots__/SuperVideo.test.ts.snap +++ b/src/extractor/__snapshots__/SuperVideo.test.ts.snap @@ -11,6 +11,7 @@ exports[`SuperVideo embed only 1`] = ` "countryCodes": [ "it", ], + "height": undefined, "title": "", }, "sourceId": "supervideo_it",