* allow 0000-2999 SSEE patterns

@see http://www.filebot.net/forums/viewtopic.php?f=6&t=907
This commit is contained in:
Reinhard Pointner 2013-08-31 06:51:30 +00:00
parent 4066124dff
commit 9ff34da4cf
2 changed files with 36 additions and 39 deletions

View File

@ -2,9 +2,11 @@
package net.sourceforge.filebot.similarity;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.util.regex.Pattern.*;
import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.UNICODE_CASE;
import static java.util.regex.Pattern.compile;
import java.io.File;
import java.util.ArrayList;
@ -70,7 +72,7 @@ public class SeasonEpisodeMatcher {
};
// match patterns like 01, 102, 1003 (enclosed in separators)
patterns[4] = new SeasonEpisodePattern(sanity, "(?<!\\p{Alnum})([0-1]?\\d?)(\\d{2})(?!\\p{Alnum})") {
patterns[4] = new SeasonEpisodePattern(sanity, "(?<!\\p{Alnum})([0-2]?\\d?)(\\d{2})(?!\\p{Alnum})") {
@Override
protected Collection<SxE> process(MatchResult match) {

View File

@ -1,101 +1,96 @@
package net.sourceforge.filebot.similarity;
import static java.util.Arrays.*;
import static net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE.*;
import static org.junit.Assert.*;
import static java.util.Arrays.asList;
import static net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE.UNDEFINED;
import static org.junit.Assert.assertEquals;
import net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE;
import org.junit.Test;
public class SeasonEpisodeMatcherTest {
private static SeasonEpisodeMatcher matcher = new SeasonEpisodeMatcher(null, false);
@Test
public void patternPrecedence() {
// S01E01 pattern has highest precedence
assertEquals(new SxE(1, 3), matcher.match("Test.101.1x02.S01E03").get(0));
// multiple values
assertEquals(new SxE(1, 2), matcher.match("Test.42.s01e01.s01e02.300").get(1));
}
@Test
public void pattern_1x01() {
assertEquals(new SxE(1, 1), matcher.match("1x01").get(0));
// test multiple matches
assertEquals(new SxE(1, 2), matcher.match("Test - 1x01 and 1x02 - Multiple MatchCollection").get(1));
// test high values
assertEquals(new SxE(12, 345), matcher.match("Test - 12x345 - High Values").get(0));
// test look-ahead and look-behind
assertEquals(new SxE(1, 3), matcher.match("Test_-_103_[1280x720]").get(0));
}
@Test
public void pattern_S01E01() {
assertEquals(new SxE(1, 1), matcher.match("S01E01").get(0));
assertEquals(new SxE(2010, 0), matcher.match("S2010E00").get(0));
// test multiple matches
assertEquals(new SxE(1, 2), matcher.match("S01E01 and S01E02 - Multiple MatchCollection").get(1));
// test separated values
assertEquals(new SxE(1, 3), matcher.match("[s01]_[e03]").get(0));
// test high values
assertEquals(new SxE(12, 345), matcher.match("Test - S12E345 - High Values").get(0));
}
@Test
public void pattern_101() {
assertEquals(new SxE(1, 1), matcher.match("Test.101").get(0));
// test 2-digit number
assertEquals(new SxE(UNDEFINED, 2), matcher.match("02").get(0));
// test high values
assertEquals(new SxE(10, 1), matcher.match("[Test]_1001_High_Values").get(0));
// test season digits <= 19
assertEquals(null, matcher.match("The 4400"));
// test look-behind
assertEquals(null, matcher.match("720p"));
// test ambiguous match processing
assertEquals(asList(new SxE(1, 1), new SxE(UNDEFINED, 101)), matcher.match("Test.101"));
// test 4-digit
assertEquals(asList(new SxE(23, 21), new SxE(null, 2321)), matcher.match("the.simpsons.2321.hdtv-lol"));
}
@Test
public void multiEpisodePatterns() {
assertEquals(new SxE(1, 1), matcher.match("s01e01-02-03-04").get(0));
assertEquals(new SxE(1, 4), matcher.match("s01e01-02-03-04").get(3));
assertEquals(new SxE(1, 1), matcher.match("s01e01e02e03e04").get(0));
assertEquals(new SxE(1, 4), matcher.match("s01e01e02e03e04").get(3));
assertEquals(new SxE(1, 1), matcher.match("1x01-02-03-04").get(0));
assertEquals(new SxE(1, 4), matcher.match("1x01-02-03-04").get(3));
assertEquals(new SxE(1, 1), matcher.match("1x01x02x03x04").get(0));
assertEquals(new SxE(1, 4), matcher.match("1x01x02x03x04").get(3));
assertEquals(new SxE(1, 1), matcher.match("[s01]_[e01-02-03-04]").get(0));
assertEquals(new SxE(1, 4), matcher.match("[s01]_[e01-02-03-04]").get(3));
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));
}
}