From 751ec8ec91b9c514293ba9bbb519df6969c57c28 Mon Sep 17 00:00:00 2001 From: Courville Software Date: Sun, 7 Jul 2024 17:26:44 +0200 Subject: [PATCH] Fixes https://github.com/nova-video-player/aos-AVP/issues/1240 seen on sentry --- .../themoviedb3/MovieIdParser2.java | 4 ++-- .../themoviedb3/SearchMovieParser2.java | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/com/archos/mediascraper/themoviedb3/MovieIdParser2.java b/src/com/archos/mediascraper/themoviedb3/MovieIdParser2.java index 8c1832cd..4b9c1e9e 100644 --- a/src/com/archos/mediascraper/themoviedb3/MovieIdParser2.java +++ b/src/com/archos/mediascraper/themoviedb3/MovieIdParser2.java @@ -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); @@ -127,7 +127,7 @@ public static MovieTags getResult(Movie movie, Context context) { if (movie.runtime != null) result.setRuntime(movie.runtime, TimeUnit.MINUTES); List 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) { diff --git a/src/com/archos/mediascraper/themoviedb3/SearchMovieParser2.java b/src/com/archos/mediascraper/themoviedb3/SearchMovieParser2.java index 302c6381..14b80cb4 100644 --- a/src/com/archos/mediascraper/themoviedb3/SearchMovieParser2.java +++ b/src/com/archos/mediascraper/themoviedb3/SearchMovieParser2.java @@ -53,9 +53,12 @@ private static SearchParserResult getSearchMovieParserResult(Response 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()) @@ -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; }