Improved support for absolute multi-episode patterns

@see https://www.filebot.net/forums/viewtopic.php?f=10&t=4371&p=24494#p24485
This commit is contained in:
Reinhard Pointner 2016-11-22 07:01:51 +08:00
parent cb499b0590
commit b6c2329e79
2 changed files with 5 additions and 3 deletions

View File

@ -65,8 +65,8 @@ public class SeasonEpisodeMatcher {
});
// match patterns like ep1, ep.1, ...
EP0 = new SeasonEpisodePattern(sanity, "(?<!\\p{Alnum})(\\d{2}|\\d{4})?[^\\p{Alnum}]{0,3}(?i:e|ep|episode|p|part)[^\\p{Alnum}]{0,3}(\\d{1,3})(?!\\p{Digit})", m -> {
return single(m.group(1), m.group(2));
EP0 = new SeasonEpisodePattern(sanity, "(?<!\\p{Alnum})(\\d{2}|\\d{4})?[\\P{Alnum}]{0,3}(((?i:e|ep|episode|p|part)[\\P{Alnum}]{0,3}\\d{1,3})+)(?!\\p{Digit})", m -> {
return multi(m.group(1), m.group(2));
});
// match patterns like 01, 102, 1003, 10102 (enclosed in separators)
@ -100,7 +100,7 @@ public class SeasonEpisodeMatcher {
}
protected List<SxE> multi(String season, String... episodes) {
int s = Integer.parseInt(season);
Integer s = matchInteger(season);
return stream(episodes).flatMap(e -> matchIntegers(e).stream()).map(e -> new SxE(s, e)).collect(toList());
}

View File

@ -107,6 +107,8 @@ public class SeasonEpisodeMatcherTest {
assertEquals(new SxE(1, 1), matcher.match("1x01.1x02.1x03.1x04").get(0));
assertEquals(new SxE(1, 4), matcher.match("1x01.1x02.1x03.1x04").get(3));
assertEquals(new SxE(null, 4), matcher.match("E1E2E3E4").get(3));
}
@Test