range patterns without season are more prone to false positives, so we need to do some extra sanity checks (e.g. Episode 01-50 is probably not a multi-episode but some sort of season pack)
This commit is contained in:
parent
1467003565
commit
82f34a0043
@ -112,6 +112,11 @@ public class SeasonEpisodeMatcher {
|
||||
protected List<SxE> range(String season, String... episodes) {
|
||||
IntSummaryStatistics stats = stream(episodes).flatMap(s -> matchIntegers(s).stream()).mapToInt(i -> i).summaryStatistics();
|
||||
|
||||
// range patterns without season are more prone to false positives, so we need to do some extra sanity checks (e.g. Episode 01-50 is probably not a multi-episode but some sort of season pack)
|
||||
if (season == null && stats.getMax() - stats.getMin() >= 9) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
Integer s = matchInteger(season);
|
||||
return IntStream.rangeClosed(stats.getMin(), stats.getMax()).boxed().map(e -> new SxE(s, e)).collect(toList());
|
||||
}
|
||||
|
@ -116,6 +116,12 @@ public class SeasonEpisodeMatcherTest {
|
||||
assertEquals("[290, 291, 292, 293, 294, 295]", matcher.match("Episode_290-295").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiEpisodePatternsFalsePositive() {
|
||||
assertEquals("[1x01, 01, 12]", matcher.match("Complete Season 01 (EP 01-12)/01").toString());
|
||||
assertEquals("[1x01, 01, 12]", matcher.match("Complete Season 01 (EP 01-12)/12").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withReleaseInfo() {
|
||||
assertEquals("[7x20]", matcher.match("720p").toString());
|
||||
|
Loading…
Reference in New Issue
Block a user