From 4506272fe6f2fd5e1a0302d1d91ef53b22b86f8b Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 14 Nov 2011 02:02:14 +0000 Subject: [PATCH] * specifically ignore movies when parsing SxE/Airdate --- .../net/sourceforge/filebot/cli/StrictMetric.java | 2 +- .../filebot/ui/rename/MatchSimilarityMetric.java | 14 +++++++++++--- .../ui/rename/MatchSimilarityMetricTest.java | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/StrictMetric.java b/source/net/sourceforge/filebot/cli/StrictMetric.java index eeb29436..d882a97b 100644 --- a/source/net/sourceforge/filebot/cli/StrictMetric.java +++ b/source/net/sourceforge/filebot/cli/StrictMetric.java @@ -11,7 +11,7 @@ import net.sourceforge.filebot.ui.rename.MatchSimilarityMetric; public enum StrictMetric implements SimilarityMetric { EpisodeIdentifier(MatchSimilarityMetric.EpisodeIdentifier, 1), // only allow 0 or 1 - Title(MatchSimilarityMetric.Title, 2), // allow 0 or .5 or 1 + Title(MatchSimilarityMetric.SubstringFields, 2), // allow 0 or .5 or 1 Name(MatchSimilarityMetric.Name, 2); // allow 0 or .5 or 1 // inner metric diff --git a/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java b/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java index 72097098..31a984a9 100644 --- a/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java +++ b/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java @@ -72,6 +72,10 @@ public enum MatchSimilarityMetric implements SimilarityMetric { @Override protected Collection parse(Object object) { + if (object instanceof Movie) { + return emptySet(); + } + Collection result = matchCache.get(object); if (result != null) { return result; @@ -102,6 +106,10 @@ public enum MatchSimilarityMetric implements SimilarityMetric { @Override protected Date parse(Object object) { + if (object instanceof Movie) { + return null; + } + if (object instanceof Episode) { Episode episode = (Episode) object; @@ -121,7 +129,7 @@ public enum MatchSimilarityMetric implements SimilarityMetric { }), // Match series title and episode title against folder structure and file name - Title(new SubstringMetric() { + SubstringFields(new SubstringMetric() { @Override public float getSimilarity(Object o1, Object o2) { @@ -249,9 +257,9 @@ public enum MatchSimilarityMetric implements SimilarityMetric { // 4. pass: match by generic name similarity (slow, but most matches will have been determined in second pass) // 5. pass: match by generic numeric similarity if (includeFileMetrics) { - return new SimilarityMetric[] { FileSize, EpisodeIdentifier, Title, Name, Numeric }; + return new SimilarityMetric[] { FileSize, EpisodeIdentifier, SubstringFields, Name, Numeric }; } else { - return new SimilarityMetric[] { EpisodeIdentifier, Title, Name, Numeric }; + return new SimilarityMetric[] { EpisodeIdentifier, SubstringFields, Name, Numeric }; } } diff --git a/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java b/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java index b3adbf94..20d86ba9 100644 --- a/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java +++ b/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java @@ -27,8 +27,8 @@ public class MatchSimilarityMetricTest { File fY1T1 = new File("Doctor Who (2005)/Doctor Who - 1x01 - Rose"); File fY2T2 = new File("Doctor Who (1963)/Doctor Who - 1x01 - An Unearthly Child"); - assertEquals(3.0 / 3, Title.getSimilarity(eY1T1, fY1T1), 0); - assertEquals(2.0 / 3, Title.getSimilarity(eY1T1, fY2T2), 0.01); + assertEquals(3.0 / 3, SubstringFields.getSimilarity(eY1T1, fY1T1), 0); + assertEquals(2.0 / 3, SubstringFields.getSimilarity(eY1T1, fY2T2), 0.01); } @@ -60,7 +60,7 @@ public class MatchSimilarityMetricTest { episodes.add(new Episode("Veronica Mars", null, 1, 19, "Hot Dogs")); episodes.add(new Episode("Greek", null, 1, 19, "No Campus for Old Rules")); - SimilarityMetric[] metrics = new SimilarityMetric[] { EpisodeIdentifier, Title }; + SimilarityMetric[] metrics = new SimilarityMetric[] { EpisodeIdentifier, SubstringFields }; List> m = new Matcher(files, episodes, true, metrics).match(); assertEquals("Greek - S01E19 - No Campus for Old Rules", m.get(0).getValue().getName());