From 64b74ac41780e92322536a255a0dfcc44ef2d2e5 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 2 Nov 2013 17:24:11 +0000 Subject: [PATCH] * update SxE patterns and sanity metrics @see http://www.filebot.net/forums/viewtopic.php?f=5&t=1059 --- .../filebot/similarity/SeasonEpisodeMatcher.java | 16 ++++++++++------ .../similarity/SeasonEpisodeMatcherTest.java | 11 +++++++---- website/data/series-mappings.txt | 3 ++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/source/net/sourceforge/filebot/similarity/SeasonEpisodeMatcher.java b/source/net/sourceforge/filebot/similarity/SeasonEpisodeMatcher.java index 04c68bca..1563eea4 100644 --- a/source/net/sourceforge/filebot/similarity/SeasonEpisodeMatcher.java +++ b/source/net/sourceforge/filebot/similarity/SeasonEpisodeMatcher.java @@ -18,7 +18,7 @@ import java.util.regex.Pattern; public class SeasonEpisodeMatcher { - public static final SeasonEpisodeFilter DEFAULT_SANITY = new SeasonEpisodeFilter(50, 50, 1000); + public static final SeasonEpisodeFilter DEFAULT_SANITY = new SeasonEpisodeFilter(50, 50, 1000, 1970, 2100); private SeasonEpisodePattern[] patterns; private Pattern seasonPattern; @@ -30,7 +30,7 @@ public class SeasonEpisodeMatcher { patterns[0] = new SeasonEpisodePattern(null, "(? process(MatchResult match) { @@ -72,12 +72,12 @@ public class SeasonEpisodeMatcher { }; // match patterns like ep1, ep.1, ... - patterns[4] = new SeasonEpisodePattern(sanity, "(? process(MatchResult match) { // regex doesn't match season - return singleton(new SxE(null, match.group(1))); + return singleton(new SxE(match.group(1), match.group(2))); } }; @@ -236,15 +236,19 @@ public class SeasonEpisodeMatcher { public final int seasonLimit; public final int seasonEpisodeLimit; public final int absoluteEpisodeLimit; + public final int seasonYearBegin; + public final int seasonYearEnd; - public SeasonEpisodeFilter(int seasonLimit, int seasonEpisodeLimit, int absoluteEpisodeLimit) { + public SeasonEpisodeFilter(int seasonLimit, int seasonEpisodeLimit, int absoluteEpisodeLimit, int seasonYearBegin, int seasonYearEnd) { this.seasonLimit = seasonLimit; this.seasonEpisodeLimit = seasonEpisodeLimit; this.absoluteEpisodeLimit = absoluteEpisodeLimit; + this.seasonYearBegin = seasonYearBegin; + this.seasonYearEnd = seasonYearEnd; } boolean filter(SxE sxe) { - return (sxe.season >= 0 && sxe.season < seasonLimit && sxe.episode < seasonEpisodeLimit) || (sxe.season < 0 && sxe.episode < absoluteEpisodeLimit); + return (sxe.season >= 0 && (sxe.season < seasonLimit || (sxe.season > seasonYearBegin && sxe.season < seasonYearEnd)) && sxe.episode < seasonEpisodeLimit) || (sxe.season < 0 && sxe.episode < absoluteEpisodeLimit); } } diff --git a/test/net/sourceforge/filebot/similarity/SeasonEpisodeMatcherTest.java b/test/net/sourceforge/filebot/similarity/SeasonEpisodeMatcherTest.java index 682432c1..a14b127f 100644 --- a/test/net/sourceforge/filebot/similarity/SeasonEpisodeMatcherTest.java +++ b/test/net/sourceforge/filebot/similarity/SeasonEpisodeMatcherTest.java @@ -9,13 +9,16 @@ import org.junit.Test; public class SeasonEpisodeMatcherTest { - private static SeasonEpisodeMatcher matcher = new SeasonEpisodeMatcher(null, false); + private static SeasonEpisodeMatcher matcher = new SeasonEpisodeMatcher(SeasonEpisodeMatcher.DEFAULT_SANITY, false); @Test public void patternPrecedence() { // S01E01 pattern has highest precedence assertEquals(new SxE(1, 3), matcher.match("Test.101.1x02.S01E03").get(0)); + assertEquals(new SxE(1, 2), matcher.match("[s01]_[e02]").get(0)); + assertEquals(new SxE(2013, 10), matcher.match("2013.P10").get(0)); + // multiple values assertEquals(new SxE(1, 2), matcher.match("Test.42.s01e01.s01e02.300").get(1)); } @@ -28,7 +31,7 @@ public class SeasonEpisodeMatcherTest { 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)); + assertEquals(null, matcher.match("Test - 12x345 - High Values")); // test look-ahead and look-behind assertEquals(new SxE(1, 3), matcher.match("Test_-_103_[1280x720]").get(0)); @@ -63,7 +66,7 @@ public class SeasonEpisodeMatcherTest { assertEquals(new SxE(10, 1), matcher.match("[Test]_1001_High_Values").get(0)); // test season digits <= 19 - assertEquals(null, matcher.match("The 4400")); + assertEquals(new SxE(null, 16), matcher.match("E16").get(0)); // test look-behind assertEquals(null, matcher.match("720p")); @@ -72,7 +75,7 @@ public class SeasonEpisodeMatcherTest { 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")); + assertEquals(asList(new SxE(23, 21)), matcher.match("the.simpsons.2321.hdtv-lol")); } @Test diff --git a/website/data/series-mappings.txt b/website/data/series-mappings.txt index 8d81616c..1e2e199e 100644 --- a/website/data/series-mappings.txt +++ b/website/data/series-mappings.txt @@ -11,4 +11,5 @@ NCIS.LA NCIS: Los Angeles SuiG7p Suits tvs.got Game of Thrones UndG7p Underemployed -vampire The Vampire Diaries \ No newline at end of file +vampire The Vampire Diaries +wsop World Series of Poker \ No newline at end of file