SxE sequences must increase in linear order (e.g. multi episode 04-05 is allowed but Episode 05-04 will not be interpreted as multi episode)

@see https://www.filebot.net/forums/viewtopic.php?f=8&t=4507&p=25067#p25067
This commit is contained in:
Reinhard Pointner 2016-12-14 11:01:04 +08:00
parent 189a0fb52e
commit 77512d0e4f
2 changed files with 12 additions and 2 deletions

View File

@ -219,7 +219,7 @@ public class SeasonEpisodeMatcher {
return null;
}
public static class SxE {
public static class SxE implements Comparable<SxE> {
public static final int UNDEFINED = -1;
@ -254,6 +254,11 @@ public class SeasonEpisodeMatcher {
return false;
}
@Override
public int compareTo(SxE other) {
return season < other.season ? -1 : season != other.season ? 1 : episode < other.episode ? -1 : episode != other.episode ? 1 : 0;
}
@Override
public int hashCode() {
return Objects.hash(season, episode);
@ -324,7 +329,9 @@ public class SeasonEpisodeMatcher {
while (matcher.find()) {
for (SxE value : process.apply(matcher)) {
if (sanity == null || sanity.filter(value)) {
matches.add(value);
if (matches.isEmpty() || matches.get(matches.size() - 1).compareTo(value) < 0) {
matches.add(value);
}
}
}
}

View File

@ -109,6 +109,9 @@ public class SeasonEpisodeMatcherTest {
assertEquals(new SxE(1, 4), matcher.match("1x01.1x02.1x03.1x04").get(3));
assertEquals(new SxE(null, 4), matcher.match("E1E2E3E4").get(3));
assertEquals("[05]", matcher.match("05.Chapter.04+1").toString());
}
@Test