From 862d3bb5f23c32dcf4f4e3399a9a79e28a66ab12 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Thu, 29 May 2025 17:40:48 +0000 Subject: [PATCH] refactor(handler): remove not needed 404 special handling --- src/handler/Frembed.test.ts | 5 ----- src/handler/Frembed.ts | 21 +-------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/handler/Frembed.test.ts b/src/handler/Frembed.test.ts index aa5a78c..db564e1 100644 --- a/src/handler/Frembed.test.ts +++ b/src/handler/Frembed.test.ts @@ -17,11 +17,6 @@ describe('Frembed', () => { expect(streams).toHaveLength(0); }); - test('handles non-existent series gracefully', async () => { - const streams = await handler.handle(ctx, 'series', 'tt4352342:1:1'); - expect(streams).toHaveLength(0); - }); - test('handle imdb black mirror s4e2', async () => { const streams = (await handler.handle(ctx, 'series', 'tt2085059:4:2')).filter(stream => stream !== undefined); expect(streams).toMatchSnapshot(); diff --git a/src/handler/Frembed.ts b/src/handler/Frembed.ts index b4dcc83..4ccdd61 100644 --- a/src/handler/Frembed.ts +++ b/src/handler/Frembed.ts @@ -1,4 +1,3 @@ -import axios from 'axios'; import { Handler } from './types'; import { parseImdbId, Fetcher, getTmdbIdFromImdbId } from '../utils'; import { ExtractorRegistry } from '../extractor'; @@ -29,12 +28,8 @@ export class Frembed implements Handler { const tmdbId = await getTmdbIdFromImdbId(ctx, this.fetcher, parseImdbId(id)); const apiUrl = new URL(`https://frembed.club/api/series?id=${tmdbId.id}&sa=${tmdbId.series}&epi=${tmdbId.episode}&idType=tmdb`); - const response = await this.apiCall(ctx, apiUrl); - if (!response) { - return []; - } - const json = JSON.parse(response); + const json = JSON.parse(await this.fetcher.text(ctx, apiUrl)); const urls: URL[] = []; for (const key in json) { @@ -51,18 +46,4 @@ export class Frembed implements Handler { urls.map(url => this.extractorRegistry.handle({ ...ctx, referer: apiUrl }, url, { countryCode: 'fr', title: `${json['title']} ${tmdbId.series}x${tmdbId.episode}` })), ); }; - - private readonly apiCall = async (ctx: Context, url: URL): Promise => { - try { - return await this.fetcher.text(ctx, url); - } catch (error) { - /* istanbul ignore next */ - if (axios.isAxiosError(error) && error.response?.status === 404) { - return undefined; - } - - /* istanbul ignore next */ - throw error; - } - }; }