chore(handler): add height detection to Soaper
This commit is contained in:
parent
2d9f602256
commit
7d0544a590
4 changed files with 5931 additions and 2 deletions
|
|
@ -2,6 +2,11 @@ import { Extractor } from './types';
|
|||
import { Fetcher } from '../utils';
|
||||
import { Context, Meta } from '../types';
|
||||
|
||||
interface SoaperInfoResponsePartial {
|
||||
val: string;
|
||||
val_bak: string;
|
||||
}
|
||||
|
||||
export class Soaper implements Extractor {
|
||||
readonly id = 'soaper';
|
||||
|
||||
|
|
@ -37,14 +42,21 @@ export class Soaper implements Extractor {
|
|||
},
|
||||
},
|
||||
);
|
||||
const jsonResponse = JSON.parse(response);
|
||||
const jsonResponse = JSON.parse(response) as SoaperInfoResponsePartial;
|
||||
|
||||
const m3u8Url = new URL(jsonResponse['val'], url.origin);
|
||||
const m3u8Data = await this.fetcher.text(ctx, m3u8Url);
|
||||
const height = m3u8Data.match(/\d+x(\d+)|(\d+)p/) as string[];
|
||||
|
||||
return {
|
||||
url: new URL(jsonResponse['val'], url.origin),
|
||||
label: this.label,
|
||||
sourceId: `${this.id}_${meta.countryCode.toLowerCase()}`,
|
||||
ttl: this.ttl,
|
||||
meta,
|
||||
meta: {
|
||||
...(height && { height: parseInt(height[1] ?? height[2] as string) }),
|
||||
...meta,
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ exports[`Soaper handle imdb black mirror s4e2 1`] = `
|
|||
"label": "Soaper",
|
||||
"meta": {
|
||||
"countryCode": "en",
|
||||
"height": 720,
|
||||
"title": "Black Mirror 4x2",
|
||||
},
|
||||
"sourceId": "soaper_en",
|
||||
|
|
@ -21,6 +22,7 @@ exports[`Soaper handle imdb full metal jacket 1`] = `
|
|||
"label": "Soaper",
|
||||
"meta": {
|
||||
"countryCode": "en",
|
||||
"height": 1080,
|
||||
"title": "Full Metal Jacket (1987)",
|
||||
},
|
||||
"sourceId": "soaper_en",
|
||||
|
|
@ -36,6 +38,7 @@ exports[`Soaper handle tmdb black mirror s4e2 1`] = `
|
|||
"label": "Soaper",
|
||||
"meta": {
|
||||
"countryCode": "en",
|
||||
"height": 720,
|
||||
"title": "Black Mirror 4x2",
|
||||
},
|
||||
"sourceId": "soaper_en",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue