Avoid NPE

This commit is contained in:
Reinhard Pointner 2016-08-01 22:26:20 +08:00
parent 361e15508c
commit 1c21c37285
2 changed files with 4 additions and 6 deletions

View File

@ -730,11 +730,8 @@ public class MediaDetection {
if (similarity >= 1) {
return true;
} else if (similarity >= 0.5 && e.getSeason() == null && e.getEpisode() != null && e.getSpecial() == null) {
for (SxE it : parseEpisodeNumber(f, false)) {
if (it.season < 0 && it.episode == e.getEpisode()) {
return true;
}
}
List<SxE> numbers = parseEpisodeNumber(f, false);
return numbers != null && numbers.stream().anyMatch(it -> it.season < 0 && it.episode == e.getEpisode());
}
return false;
}

View File

@ -26,6 +26,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Predicate;
@ -170,7 +171,7 @@ public final class SubtitleUtilities {
if (searchBySeries) {
// search for subtitles for the given files
List<SxE> numbers = files.stream().flatMap(f -> parseEpisodeNumber(f, true).stream()).distinct().collect(toList());
List<SxE> numbers = files.stream().map(f -> parseEpisodeNumber(f, true)).filter(Objects::nonNull).flatMap(Collection::stream).distinct().collect(toList());
if (numbers.size() == 1) {
episodeFilter = numbers.stream().map(sxe -> new int[] { sxe.season, sxe.episode }).toArray(int[][]::new); // season-and-episode filter