Skip to content

Commit

Permalink
Fixes nova-video-player/aos-AVP#1240 seen on sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
courville committed Jul 7, 2024
1 parent 5f6fa3c commit 751ec8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/com/archos/mediascraper/themoviedb3/MovieIdParser2.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static MovieTags getResult(Movie movie, Context context) {
if (movie.release_dates != null && movie.release_dates.results != null) {
for (int i = 0; i < movie.release_dates.results.size(); i++) {
ReleaseDatesResult releaseDatesResult = movie.release_dates.results.get(i);
if (releaseDatesResult.iso_3166_1.equals("US")) {
if (releaseDatesResult.iso_3166_1 != null && releaseDatesResult.iso_3166_1.equals("US")) {
for (int j = 0; j < releaseDatesResult.release_dates.size(); j++) {
ReleaseDate releaseDate = releaseDatesResult.release_dates.get(j);
result.setContentRating(releaseDate.certification);
Expand All @@ -127,7 +127,7 @@ public static MovieTags getResult(Movie movie, Context context) {
if (movie.runtime != null) result.setRuntime(movie.runtime, TimeUnit.MINUTES);

List<ScraperTrailer> trailers;
if (movie.videos != null) {
if (movie.videos != null && movie.videos.results != null) {
trailers = new ArrayList<>(movie.videos.results.size());
int i = 0;
for (Videos.Video trailer: movie.videos.results) {
Expand Down
18 changes: 12 additions & 6 deletions src/com/archos/mediascraper/themoviedb3/SearchMovieParser2.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ private static SearchParserResult getSearchMovieParserResult(Response<MovieResul
SearchParserResult searchMovieParserResult = new SearchParserResult();
int levenshteinDistanceTitle, levenshteinDistanceOriginalTitle;
log.debug("getSearchMovieParserResult: examining response of " + response.body().total_results + " entries in " + language + ", for " + movieName + " and specific year " + year);

// sort first movies by popularity so that distinction between levenstein distance is operated on popularity
List<BaseMovie> resultsMovie = response.body().results;
if (resultsMovie == null) {
log.debug("getSearchMovieParserResult: no results");
return searchMovieParserResult;
}
// popularity sort is disabled to enable sort by year to pick lower year if not specified with lowest levenshtein metric
// if year is specified pick movies with highest popularity (solves The Killer 1989 best pick)
if (SORT_POPULARITY && year != null && ! year.isEmpty())
Expand Down Expand Up @@ -149,11 +152,14 @@ public int compare(final BaseMovie bm1, final BaseMovie bm2) {
log.debug("getSearchMovieParserResult: resultsProbable=" + searchMovieParserResult.resultsProbable.toString());

// perform the levenshtein distance sort on all results
Collections.sort(searchMovieParserResult.resultsProbable, SearchParserResult.comparator);
Collections.sort(searchMovieParserResult.resultsNoBanner, SearchParserResult.comparator);
Collections.sort(searchMovieParserResult.resultsNoPoster, SearchParserResult.comparator);
Collections.sort(searchMovieParserResult.resultsNoAirDate, SearchParserResult.comparator);

if (searchMovieParserResult.resultsProbable != null)
Collections.sort(searchMovieParserResult.resultsProbable, SearchParserResult.comparator);
if (searchMovieParserResult.resultsNoBanner != null)
Collections.sort(searchMovieParserResult.resultsNoBanner, SearchParserResult.comparator);
if (searchMovieParserResult.resultsNoPoster != null)
Collections.sort(searchMovieParserResult.resultsNoPoster, SearchParserResult.comparator);
if (searchMovieParserResult.resultsNoAirDate != null)
Collections.sort(searchMovieParserResult.resultsNoAirDate, SearchParserResult.comparator);
log.debug("getSearchMovieParserResult: applying Levenshtein distance resultsProbableSorted=" + searchMovieParserResult.resultsProbable.toString());
return searchMovieParserResult;
}
Expand Down

0 comments on commit 751ec8e

Please sign in to comment.