refactor(handler): remove not needed 404 special handling

This commit is contained in:
WebStreamr 2025-05-29 17:40:48 +00:00
parent 02b73b41d7
commit 862d3bb5f2
No known key found for this signature in database
2 changed files with 1 additions and 25 deletions

View file

@ -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();

View file

@ -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<string | undefined> => {
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;
}
};
}