Skip to content

Commit

Permalink
fix(tmdb): fallback movie/show overview to English when none is avail…
Browse files Browse the repository at this point in the history
…able in requested locale (#928)

This PR adds a second call to TMDB to retried the overview in English if no overview is available in
the requested locale

fix #925
  • Loading branch information
gauthier-th authored Aug 13, 2024
1 parent 61dcd8e commit 12f908d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 9 additions & 3 deletions server/routes/movie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ movieRoutes.get('/:id', async (req, res, next) => {
},
});

return res
.status(200)
.json(mapMovieDetails(tmdbMovie, media, onUserWatchlist));
const data = mapMovieDetails(tmdbMovie, media, onUserWatchlist);

// TMDB issue where it doesnt fallback to English when no overview is available in requested locale.
if (!data.overview) {
const tvEnglish = await tmdb.getMovie({ movieId: Number(req.params.id) });
data.overview = tvEnglish.overview;
}

return res.status(200).json(data);
} catch (e) {
logger.debug('Something went wrong retrieving movie', {
label: 'API',
Expand Down
10 changes: 9 additions & 1 deletion server/routes/tv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ tvRoutes.get('/:id', async (req, res, next) => {
},
});

return res.status(200).json(mapTvDetails(tv, media, onUserWatchlist));
const data = mapTvDetails(tv, media, onUserWatchlist);

// TMDB issue where it doesnt fallback to English when no overview is available in requested locale.
if (!data.overview) {
const tvEnglish = await tmdb.getTvShow({ tvId: Number(req.params.id) });
data.overview = tvEnglish.overview;
}

return res.status(200).json(data);
} catch (e) {
logger.debug('Something went wrong retrieving series', {
label: 'API',
Expand Down

0 comments on commit 12f908d

Please sign in to comment.