fix(source): handle non-existent content gracefully via Movix

This commit is contained in:
WebStreamr 2025-07-13 19:33:04 +00:00
parent c60e958920
commit 599e6eaf7e
No known key found for this signature in database
4 changed files with 13 additions and 1 deletions

View file

@ -11,6 +11,11 @@ describe('Movix', () => {
handler = new Movix(new FetcherMock(`${__dirname}/__fixtures__/Movix`));
});
test('handles non-existent content gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new TmdbId(46080, 1, 999));
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

@ -32,7 +32,11 @@ export class Movix implements Source {
: new URL(`/api/tmdb/movie/${tmdbId.id}`, this.baseUrl);
const json = JSON.parse(await this.fetcher.text(ctx, apiUrl));
const data: MovixApiData = tmdbId.season ? json['current_episode'] : json;
const data: MovixApiData | undefined = tmdbId.season ? json['current_episode'] : json;
if (!data) {
return [];
}
const urls: URL[] = data['player_links'].map(({ decoded_url }) => new URL(decoded_url));

View file

@ -0,0 +1 @@
{"message":"Contenu non disponible","tmdb_id":"46080","tmdb_details":{"id":46080,"title":"Masha et Michka","original_title":"Маша и Медведь","release_date":"2009-01-07","poster_path":"/ruQSBtzk5d6mQHLoiBvOQEr728R.jpg","backdrop_path":"/uu2qZZ82Ml2u6SgOd68OIIOI0si.jpg","overview":"Masha est une petite fille qui n'arrive pas facilement à se poser tant son énergie est grande. Sa curiosité et sa créativité provoquent des situations comiques, même si parfois cela crée des problèmes aux autres. L'ours, Michka, est un ami au coeur tendre qui voit son monde tranquille bouleversé dès que Masha entre en action...","vote_average":6.9}}

View file

@ -134,3 +134,5 @@ exports[`Movix handle tmdb black mirror s4e2 1`] = `
},
]
`;
exports[`Movix handles non-existent content gracefully 1`] = `[]`;