mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 04:08:45 -05:00
feat: rotten tomatoes scores on movie/tv details pages
This commit is contained in:
@@ -4,6 +4,7 @@ import { MediaRequest } from '../entity/MediaRequest';
|
||||
import { mapTvDetails, mapSeasonWithEpisodes } from '../models/Tv';
|
||||
import { mapTvResult } from '../models/Search';
|
||||
import Media from '../entity/Media';
|
||||
import RottenTomatoes from '../api/rottentomatoes';
|
||||
|
||||
const tvRoutes = Router();
|
||||
|
||||
@@ -84,4 +85,28 @@ tvRoutes.get('/:id/similar', async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
tvRoutes.get('/:id/ratings', async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
const rtapi = new RottenTomatoes();
|
||||
|
||||
const tv = await tmdb.getTvShow({
|
||||
tvId: Number(req.params.id),
|
||||
});
|
||||
|
||||
if (!tv) {
|
||||
return next({ status: 404, message: 'TV Show does not exist' });
|
||||
}
|
||||
|
||||
const rtratings = await rtapi.getTVRatings(
|
||||
tv.name,
|
||||
Number(tv.first_air_date.slice(0, 4))
|
||||
);
|
||||
|
||||
if (!rtratings) {
|
||||
return next({ status: 404, message: 'Unable to retrieve ratings' });
|
||||
}
|
||||
|
||||
return res.status(200).json(rtratings);
|
||||
});
|
||||
|
||||
export default tvRoutes;
|
||||
|
||||
Reference in New Issue
Block a user