* specifically ignore movies when parsing SxE/Airdate

This commit is contained in:
Reinhard Pointner 2011-11-14 02:02:14 +00:00
parent 9c55decf67
commit 4506272fe6
3 changed files with 15 additions and 7 deletions

View File

@ -11,7 +11,7 @@ import net.sourceforge.filebot.ui.rename.MatchSimilarityMetric;
public enum StrictMetric implements SimilarityMetric { public enum StrictMetric implements SimilarityMetric {
EpisodeIdentifier(MatchSimilarityMetric.EpisodeIdentifier, 1), // only allow 0 or 1 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 Name(MatchSimilarityMetric.Name, 2); // allow 0 or .5 or 1
// inner metric // inner metric

View File

@ -72,6 +72,10 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
@Override @Override
protected Collection<SxE> parse(Object object) { protected Collection<SxE> parse(Object object) {
if (object instanceof Movie) {
return emptySet();
}
Collection<SxE> result = matchCache.get(object); Collection<SxE> result = matchCache.get(object);
if (result != null) { if (result != null) {
return result; return result;
@ -102,6 +106,10 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
@Override @Override
protected Date parse(Object object) { protected Date parse(Object object) {
if (object instanceof Movie) {
return null;
}
if (object instanceof Episode) { if (object instanceof Episode) {
Episode episode = (Episode) object; 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 // Match series title and episode title against folder structure and file name
Title(new SubstringMetric() { SubstringFields(new SubstringMetric() {
@Override @Override
public float getSimilarity(Object o1, Object o2) { 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) // 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 // 5. pass: match by generic numeric similarity
if (includeFileMetrics) { if (includeFileMetrics) {
return new SimilarityMetric[] { FileSize, EpisodeIdentifier, Title, Name, Numeric }; return new SimilarityMetric[] { FileSize, EpisodeIdentifier, SubstringFields, Name, Numeric };
} else { } else {
return new SimilarityMetric[] { EpisodeIdentifier, Title, Name, Numeric }; return new SimilarityMetric[] { EpisodeIdentifier, SubstringFields, Name, Numeric };
} }
} }

View File

@ -27,8 +27,8 @@ public class MatchSimilarityMetricTest {
File fY1T1 = new File("Doctor Who (2005)/Doctor Who - 1x01 - Rose"); File fY1T1 = new File("Doctor Who (2005)/Doctor Who - 1x01 - Rose");
File fY2T2 = new File("Doctor Who (1963)/Doctor Who - 1x01 - An Unearthly Child"); File fY2T2 = new File("Doctor Who (1963)/Doctor Who - 1x01 - An Unearthly Child");
assertEquals(3.0 / 3, Title.getSimilarity(eY1T1, fY1T1), 0); assertEquals(3.0 / 3, SubstringFields.getSimilarity(eY1T1, fY1T1), 0);
assertEquals(2.0 / 3, Title.getSimilarity(eY1T1, fY2T2), 0.01); 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("Veronica Mars", null, 1, 19, "Hot Dogs"));
episodes.add(new Episode("Greek", null, 1, 19, "No Campus for Old Rules")); 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<Match<File, Episode>> m = new Matcher<File, Episode>(files, episodes, true, metrics).match(); List<Match<File, Episode>> m = new Matcher<File, Episode>(files, episodes, true, metrics).match();
assertEquals("Greek - S01E19 - No Campus for Old Rules", m.get(0).getValue().getName()); assertEquals("Greek - S01E19 - No Campus for Old Rules", m.get(0).getValue().getName());