fix(extractor): support DoodStream via cloudflarestorage
This commit is contained in:
parent
a371f86933
commit
25d32117ed
5 changed files with 40 additions and 4 deletions
|
|
@ -26,4 +26,8 @@ describe('DoodStream', () => {
|
|||
test('can guess height from title', async () => {
|
||||
expect(await extractorRegistry.handle(ctx, new URL('https://do7go.com/e/dfx8me4un4ul'), CountryCode.fr)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('cloudflare storage', async () => {
|
||||
expect(await extractorRegistry.handle(ctx, new URL('https://doodstream.com/e/wfpwtsgyr1xi'), CountryCode.mx)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -44,9 +44,17 @@ export class DoodStream extends Extractor {
|
|||
const $ = cheerio.load(html);
|
||||
const title = $('title').text().trim().replace(/ - DoodStream$/, '').trim();
|
||||
|
||||
const mp4Url = new URL(`${baseUrl}${randomstring.generate(10)}?token=${token}&expiry=${Date.now()}`);
|
||||
|
||||
const mp4Head = await this.fetcher.head(ctx, mp4Url, { headers: { Referer: url.origin } });
|
||||
let mp4Url: URL;
|
||||
let bytes: number | undefined;
|
||||
if (baseUrl.includes('cloudflarestorage')) {
|
||||
mp4Url = new URL(baseUrl);
|
||||
} else {
|
||||
mp4Url = new URL(`${baseUrl}${randomstring.generate(10)}?token=${token}&expiry=${Date.now()}`);
|
||||
const mp4Head = await this.fetcher.head(ctx, mp4Url, { headers: { Referer: url.origin } });
|
||||
if (mp4Head['content-length']) {
|
||||
bytes = parseInt(mp4Head['content-length'] as string);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
|
|
@ -58,7 +66,7 @@ export class DoodStream extends Extractor {
|
|||
meta: {
|
||||
countryCodes: [countryCode],
|
||||
title,
|
||||
...(mp4Head['content-length'] && { bytes: parseInt(mp4Head['content-length'] as string) }),
|
||||
...(bytes && { bytes }),
|
||||
},
|
||||
requestHeaders: {
|
||||
Referer: url.origin,
|
||||
|
|
|
|||
1
src/extractor/__fixtures__/DoodStream/http:dood.toewfpwtsgyr1xi
generated
Normal file
1
src/extractor/__fixtures__/DoodStream/http:dood.toewfpwtsgyr1xi
generated
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
https://wec6bnh7rx7rw11bv9e9vslw4rud8nam.5f1ebd98099ce35faeeddb30c1752191.r2.cloudflarestorage.com/icxxqqdsfdc4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ab085b515b950aae0a86cae59456cacd%2F20250714%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20250714T154400Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=845ebfa5feedd840027e431f31e013513dd4c4f74364b4e75a2c8ddb213bd97a
|
||||
|
|
@ -22,6 +22,28 @@ exports[`DoodStream can guess height from title 1`] = `
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`DoodStream cloudflare storage 1`] = `
|
||||
[
|
||||
{
|
||||
"format": "mp4",
|
||||
"label": "DoodStream",
|
||||
"meta": {
|
||||
"countryCodes": [
|
||||
"mx",
|
||||
],
|
||||
"height": undefined,
|
||||
"title": "241653--5bf448d3-184a-4b3f-a766-fa98d93c1300--bllz--2100527-doodstream",
|
||||
},
|
||||
"requestHeaders": {
|
||||
"Referer": "http://dood.to",
|
||||
},
|
||||
"sourceId": "doodstream_mx",
|
||||
"ttl": 900000,
|
||||
"url": "https://wec6bnh7rx7rw11bv9e9vslw4rud8nam.5f1ebd98099ce35faeeddb30c1752191.r2.cloudflarestorage.com/icxxqqdsfdc4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ab085b515b950aae0a86cae59456cacd%2F20250714%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20250714T154400Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=845ebfa5feedd840027e431f31e013513dd4c4f74364b4e75a2c8ddb213bd97a",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`DoodStream dood.to 1`] = `
|
||||
[
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue