From 557efd207945ea7ada0bcaf475b0b9b9d60d8f5b Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Fri, 27 Mar 2026 17:43:01 +0000 Subject: [PATCH] fix(extractor): don't fail for HubDrive if HubCloud link is missing --- src/extractor/HubDrive.test.ts | 4 + src/extractor/HubDrive.ts | 6 +- .../https:hubdrive.spacefile2243124026 | 512 ++++++++++++++++++ .../__snapshots__/HubDrive.test.ts.snap | 2 + 4 files changed, 522 insertions(+), 2 deletions(-) create mode 100644 src/extractor/__fixtures__/HubDrive/https:hubdrive.spacefile2243124026 diff --git a/src/extractor/HubDrive.test.ts b/src/extractor/HubDrive.test.ts index af3a214..8935c50 100644 --- a/src/extractor/HubDrive.test.ts +++ b/src/extractor/HubDrive.test.ts @@ -22,4 +22,8 @@ describe('HubDrive', () => { test('handle avatar', async () => { expect(await extractorRegistry.handle(ctx, new URL('https://hubdrive.space/file/7283903021'))).toMatchSnapshot(); }); + + test('handle missing hubcloud', async () => { + expect(await extractorRegistry.handle(ctx, new URL('https://hubdrive.space/file/2243124026'))).toMatchSnapshot(); + }); }); diff --git a/src/extractor/HubDrive.ts b/src/extractor/HubDrive.ts index c4f2480..69d1622 100644 --- a/src/extractor/HubDrive.ts +++ b/src/extractor/HubDrive.ts @@ -31,8 +31,10 @@ export class HubDrive extends Extractor { const html = await this.fetcher.text(ctx, url, { headers }); const $ = cheerio.load(html); - const hubCloudUrl = new URL($('a:contains("HubCloud")').attr('href') as string); + const hubCloudUrl = $('a:contains("HubCloud")') + .map((_i, el) => new URL($(el).attr('href') as string)) + .get(0); - return this.hubCloud.extract(ctx, hubCloudUrl, meta); + return hubCloudUrl ? this.hubCloud.extract(ctx, hubCloudUrl, meta) : []; }; } diff --git a/src/extractor/__fixtures__/HubDrive/https:hubdrive.spacefile2243124026 b/src/extractor/__fixtures__/HubDrive/https:hubdrive.spacefile2243124026 new file mode 100644 index 0000000..7f4ede8 --- /dev/null +++ b/src/extractor/__fixtures__/HubDrive/https:hubdrive.spacefile2243124026 @@ -0,0 +1,512 @@ + + + + + + + + + + + + + + + + + + + +HubDrive | Back.to.the.Future.Part.III.1990.1080p.BluRay.Hindi.English.DD.5.1.x264.ESubs.Untouched.mkv + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + +
+ +
+ + + + + + + + + + + + +
+ + +
+
+
+ +
+
Back.to.the.Future.Part.III.1990.1080p.BluRay.Hindi.English.DD.5.1.x264.ESubs.Untouched.mkv
+
+
+
+ + + + + + + + + + + + + + + +
File Size3.77 GB
File Typevideo/x-matroska
File Ownerdhub 2
+
+
+
+
+ + + +
+
+ +
+ + + + + + +

+
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + +
+
+
+
+
+
+ +
+ + + + +
+
+ + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/extractor/__snapshots__/HubDrive.test.ts.snap b/src/extractor/__snapshots__/HubDrive.test.ts.snap index b246b71..6c0b076 100644 --- a/src/extractor/__snapshots__/HubDrive.test.ts.snap +++ b/src/extractor/__snapshots__/HubDrive.test.ts.snap @@ -15,3 +15,5 @@ exports[`HubDrive handle avatar 1`] = ` }, ] `; + +exports[`HubDrive handle missing hubcloud 1`] = `[]`;