fix(source): handle non-existent movies gracefully

This commit is contained in:
WebStreamr 2025-07-14 14:46:51 +00:00
parent d6e29185e5
commit a371f86933
No known key found for this signature in database
4 changed files with 12 additions and 4 deletions

View file

@ -11,11 +11,16 @@ describe('Movix', () => {
handler = new Movix(new FetcherMock(`${__dirname}/__fixtures__/Movix`));
});
test('handles non-existent content gracefully', async () => {
test('handles non-existent show gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(46080, 1, 999));
expect(streams).toMatchSnapshot();
});
test('handles non-existent movie gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(548473, undefined, undefined));
expect(streams).toMatchSnapshot();
});
test('handle tmdb black mirror s4e2', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(42009, 4, 2));
expect(streams).toMatchSnapshot();

View file

@ -4,7 +4,7 @@ import { Fetcher, getTmdbId, Id } from '../utils';
import { Source, SourceResult } from './types';
interface MovixApiData {
player_links: { decoded_url: string }[];
player_links?: { decoded_url: string }[];
}
export class Movix implements Source {
@ -34,7 +34,7 @@ export class Movix implements Source {
const json = JSON.parse(await this.fetcher.text(ctx, apiUrl));
const data: MovixApiData | undefined = tmdbId.season ? json['current_episode'] : json;
if (!data) {
if (!data || !data.player_links) {
return [];
}

View file

@ -0,0 +1 @@
{"message":"Contenu non disponible","tmdb_id":"548473","tmdb_details":{"id":548473,"title":"La couleur tombée du ciel","original_title":"Color Out of Space","release_date":"2020-01-24","poster_path":"/nVwMu8nExJIsnQt1hheoBd85wdR.jpg","backdrop_path":"/iyn2JQsftaqhQlXYaCCvn8udM5i.jpg","overview":"Après la chute dune météorite dans le jardin de leur ferme, Nathan Gardner et sa famille se retrouvent à combattre un organisme extraterrestre et mutant qui sest introduit dans leurs corps et leurs cerveaux. La quiétude de leur vie à la campagne va se transformer en cauchemar en technicolor.","vote_average":6}}

View file

@ -135,4 +135,6 @@ exports[`Movix handle tmdb black mirror s4e2 1`] = `
]
`;
exports[`Movix handles non-existent content gracefully 1`] = `[]`;
exports[`Movix handles non-existent movie gracefully 1`] = `[]`;
exports[`Movix handles non-existent show gracefully 1`] = `[]`;