chore(extractor): add DoodStream height guessing based on title
This commit is contained in:
parent
041c04e327
commit
b940df5bc0
4 changed files with 14 additions and 1 deletions
|
|
@ -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/',
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
8
src/utils/height.ts
Normal file
8
src/utils/height.ts
Normal file
|
|
@ -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;
|
||||
};
|
||||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in a new issue