Skip to content

Commit

Permalink
fix: fixes RT ratings for tv shows (#3492)
Browse files Browse the repository at this point in the history
fix #3491
  • Loading branch information
Fallenbagel committed Jun 11, 2023
1 parent 2123118 commit 04fbd00
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions server/api/rottentomatoes.ts
Expand Up @@ -17,7 +17,7 @@ interface RTAlgoliaHit {
title: string;
titles: string[];
description: string;
releaseYear: string;
releaseYear: number;
rating: string;
genres: string[];
updateDate: string;
Expand Down Expand Up @@ -111,22 +111,19 @@ class RottenTomatoes extends ExternalAPI {

// First, attempt to match exact name and year
let movie = contentResults.hits.find(
(movie) => movie.releaseYear === year.toString() && movie.title === name
(movie) => movie.releaseYear === year && movie.title === name
);

// If we don't find a movie, try to match partial name and year
if (!movie) {
movie = contentResults.hits.find(
(movie) =>
movie.releaseYear === year.toString() && movie.title.includes(name)
(movie) => movie.releaseYear === year && movie.title.includes(name)
);
}

// If we still dont find a movie, try to match just on year
if (!movie) {
movie = contentResults.hits.find(
(movie) => movie.releaseYear === year.toString()
);
movie = contentResults.hits.find((movie) => movie.releaseYear === year);
}

// One last try, try exact name match only
Expand Down Expand Up @@ -181,7 +178,7 @@ class RottenTomatoes extends ExternalAPI {

if (year) {
tvshow = contentResults.hits.find(
(series) => series.releaseYear === year.toString()
(series) => series.releaseYear === year
);
}

Expand Down

0 comments on commit 04fbd00

Please sign in to comment.