diff --git a/src/extractor/ExternalUrl.ts b/src/extractor/ExternalUrl.ts index 5b98932..9faaa26 100644 --- a/src/extractor/ExternalUrl.ts +++ b/src/extractor/ExternalUrl.ts @@ -20,8 +20,12 @@ export class ExternalUrl implements Extractor { readonly normalize = (url: URL): URL => url; readonly extract = async (ctx: Context, url: URL, meta: Meta): Promise => { - // We only want to make sure that the URL is accessible - await this.fetcher.head(ctx, url, { noFlareSolverr: true }); + try { + // Make sure the URL is accessible, but avoid causing noise and delays doing this + await this.fetcher.head(ctx, url, { noFlareSolverr: true, timeout: 1000 }); + } catch { + return []; + } return [ { diff --git a/src/extractor/ExtractorRegistry.test.ts b/src/extractor/ExtractorRegistry.test.ts index cfe4fc1..e640606 100644 --- a/src/extractor/ExtractorRegistry.test.ts +++ b/src/extractor/ExtractorRegistry.test.ts @@ -45,4 +45,10 @@ describe('ExtractorRegistry', () => { expect(urlResults1).toStrictEqual([]); expect(urlResults2).toStrictEqual([]); }); + + test('returns external url for error', async () => { + const urlResults = await extractorRegistry.handle(ctx, new URL('https://dropload.io/mocked-blocked.html'), { countryCode: 'de' }); + + expect(urlResults).toMatchSnapshot(); + }); }); diff --git a/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap b/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap index 7bced58..e5c1512 100644 --- a/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap +++ b/src/extractor/__snapshots__/ExtractorRegistry.test.ts.snap @@ -15,17 +15,20 @@ exports[`ExtractorRegistry return external URLs by default 1`] = ` ] `; -exports[`ExtractorRegistry returns error result from extractor 1`] = ` +exports[`ExtractorRegistry returns error result from extractor 1`] = `[]`; + +exports[`ExtractorRegistry returns external url for error 1`] = ` [ { - "error": [Error: TypeError: fetch failed], + "error": [Error: Fetcher error: 403: Forbidden +], "isExternal": true, - "label": "some-url.test", + "label": "dropload.io", "meta": { - "countryCode": "en", + "countryCode": "de", }, - "sourceId": "external", - "url": "https://some-url.test/", + "sourceId": "dropload", + "url": "https://dropload.io/mocked-blocked.html", }, ] `; diff --git a/src/handler/__snapshots__/Frembed.test.ts.snap b/src/handler/__snapshots__/Frembed.test.ts.snap index fe3f563..2c4ef23 100644 --- a/src/handler/__snapshots__/Frembed.test.ts.snap +++ b/src/handler/__snapshots__/Frembed.test.ts.snap @@ -44,19 +44,7 @@ exports[`Frembed handle imdb black mirror s4e2 1`] = ` "url": "https://johnalwayssame.com/e/cqy9oue7sv0g", }, ], - [ - { - "error": [Error: TypeError: fetch failed], - "isExternal": true, - "label": "ds2play.com", - "meta": { - "countryCode": "fr", - "title": "Black Mirror 4x2", - }, - "sourceId": "external", - "url": "https://ds2play.com/e/fzfvfq3ngig0", - }, - ], + [], ] `; @@ -104,18 +92,6 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = ` "url": "https://johnalwayssame.com/e/cqy9oue7sv0g", }, ], - [ - { - "error": [Error: TypeError: fetch failed], - "isExternal": true, - "label": "ds2play.com", - "meta": { - "countryCode": "fr", - "title": "Black Mirror 4x2", - }, - "sourceId": "external", - "url": "https://ds2play.com/e/fzfvfq3ngig0", - }, - ], + [], ] `; diff --git a/src/handler/__snapshots__/FrenchCloud.test.ts.snap b/src/handler/__snapshots__/FrenchCloud.test.ts.snap index d73042e..8a2ff80 100644 --- a/src/handler/__snapshots__/FrenchCloud.test.ts.snap +++ b/src/handler/__snapshots__/FrenchCloud.test.ts.snap @@ -42,18 +42,7 @@ exports[`FrenchCloud handle imdb the devil's bath 1`] = ` "url": "https://mixdrop.ag/e/l7v73zqrfdj19z", }, ], - [ - { - "error": [Error: Fetcher error: 404: Not Found], - "isExternal": true, - "label": "streamtape.com", - "meta": { - "countryCode": "fr", - }, - "sourceId": "external", - "url": "https://streamtape.com/e/gjA1OQ4klyHxgJ", - }, - ], + [], [ { "label": "DoodStream", diff --git a/src/handler/__snapshots__/KinoGer.test.ts.snap b/src/handler/__snapshots__/KinoGer.test.ts.snap index 534256e..3c7534d 100644 --- a/src/handler/__snapshots__/KinoGer.test.ts.snap +++ b/src/handler/__snapshots__/KinoGer.test.ts.snap @@ -34,19 +34,7 @@ exports[`KinoGer handle imdb blood and sinners 1`] = ` "url": "https://www.secvideo1.online/get_file/16/fae180e05d8d7af50fff44c7a24232b522db464935/900000/900576/900576.mp4/", }, ], - [ - { - "error": [Error: Fetcher error: 404: Not Found], - "isExternal": true, - "label": "kinoger.pw", - "meta": { - "countryCode": "de", - "title": "Blood & Sinners (2025)", - }, - "sourceId": "external", - "url": "https://kinoger.pw/e/6zeREaMlrqREZPa", - }, - ], + [], [ { "label": "KinoGer", diff --git a/src/handler/__snapshots__/VerHdLink.test.ts.snap b/src/handler/__snapshots__/VerHdLink.test.ts.snap index ee8fd21..5c242a9 100644 --- a/src/handler/__snapshots__/VerHdLink.test.ts.snap +++ b/src/handler/__snapshots__/VerHdLink.test.ts.snap @@ -42,18 +42,7 @@ exports[`VerHdLink handle titanic 1`] = ` "url": "https://mixdrop.ag/e/vn0wx308fq984q", }, ], - [ - { - "error": [Error: Fetcher error: 404: Not Found], - "isExternal": true, - "label": "streamtape.com", - "meta": { - "countryCode": "mx", - }, - "sourceId": "external", - "url": "https://streamtape.com/e/Bjp2vjrdBxsK82", - }, - ], + [], [], [ { diff --git a/src/utils/__fixtures__/Fetcher/https:dropload.iomocked-blocked.html.error b/src/utils/__fixtures__/Fetcher/https:dropload.iomocked-blocked.html.error new file mode 100644 index 0000000..8a1c7cd --- /dev/null +++ b/src/utils/__fixtures__/Fetcher/https:dropload.iomocked-blocked.html.error @@ -0,0 +1 @@ +Fetcher error: 403: Forbidden