* improve handling of absolute-numbered files in Strict Mode
This commit is contained in:
parent
0b617b4381
commit
836286581b
|
@ -53,7 +53,6 @@ import net.filebot.media.MediaDetection;
|
||||||
import net.filebot.media.XattrMetaInfoProvider;
|
import net.filebot.media.XattrMetaInfoProvider;
|
||||||
import net.filebot.similarity.CommonSequenceMatcher;
|
import net.filebot.similarity.CommonSequenceMatcher;
|
||||||
import net.filebot.similarity.EpisodeMatcher;
|
import net.filebot.similarity.EpisodeMatcher;
|
||||||
import net.filebot.similarity.EpisodeMetrics;
|
|
||||||
import net.filebot.similarity.Match;
|
import net.filebot.similarity.Match;
|
||||||
import net.filebot.similarity.NameSimilarityMetric;
|
import net.filebot.similarity.NameSimilarityMetric;
|
||||||
import net.filebot.similarity.SeriesNameMatcher;
|
import net.filebot.similarity.SeriesNameMatcher;
|
||||||
|
@ -269,7 +268,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
// in strict mode sanity check the result and only pass back good matches
|
// in strict mode sanity check the result and only pass back good matches
|
||||||
List<Match<File, Object>> validMatches = new ArrayList<Match<File, Object>>();
|
List<Match<File, Object>> validMatches = new ArrayList<Match<File, Object>>();
|
||||||
for (Match<File, Object> it : matches) {
|
for (Match<File, Object> it : matches) {
|
||||||
if (EpisodeMetrics.EpisodeIdentifier.getSimilarity(it.getValue(), it.getCandidate()) >= 1) {
|
if (isEpisodeNumberMatch(it.getValue(), (Episode) it.getCandidate())) {
|
||||||
validMatches.add(it);
|
validMatches.add(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import net.filebot.format.MediaBindingBean;
|
||||||
import net.filebot.similarity.CommonSequenceMatcher;
|
import net.filebot.similarity.CommonSequenceMatcher;
|
||||||
import net.filebot.similarity.DateMatcher;
|
import net.filebot.similarity.DateMatcher;
|
||||||
import net.filebot.similarity.DateMetric;
|
import net.filebot.similarity.DateMetric;
|
||||||
|
import net.filebot.similarity.EpisodeMetrics;
|
||||||
import net.filebot.similarity.MetricAvg;
|
import net.filebot.similarity.MetricAvg;
|
||||||
import net.filebot.similarity.NameSimilarityMetric;
|
import net.filebot.similarity.NameSimilarityMetric;
|
||||||
import net.filebot.similarity.NumericSimilarityMetric;
|
import net.filebot.similarity.NumericSimilarityMetric;
|
||||||
|
@ -736,6 +737,20 @@ public class MediaDetection {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isEpisodeNumberMatch(File f, Episode e) {
|
||||||
|
float similarity = EpisodeMetrics.EpisodeIdentifier.getSimilarity(f, e);
|
||||||
|
if (similarity >= 1) {
|
||||||
|
return true;
|
||||||
|
} else if (similarity >= 0.5 && e.getSeason() == null && e.getEpisode() != null && e.getSpecial() == null) {
|
||||||
|
for (SxE it : parseEpisodeNumber(f, false)) {
|
||||||
|
if (it.season < 0 && it.episode == e.getEpisode()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Integer> parseMovieYear(String name) {
|
public static List<Integer> parseMovieYear(String name) {
|
||||||
List<Integer> years = new ArrayList<Integer>();
|
List<Integer> years = new ArrayList<Integer>();
|
||||||
for (String it : name.split("\\D+")) {
|
for (String it : name.split("\\D+")) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class EpisodeMatcher extends Matcher<File, Object> {
|
||||||
|
|
||||||
public EpisodeMatcher(Collection<File> values, Collection<Episode> candidates, boolean strict) {
|
public EpisodeMatcher(Collection<File> values, Collection<Episode> candidates, boolean strict) {
|
||||||
// use strict matcher as to force a result from the final top similarity set
|
// use strict matcher as to force a result from the final top similarity set
|
||||||
super(values, candidates, strict, strict ? StrictEpisodeMetrics.defaultSequence(false) : EpisodeMetrics.defaultSequence(false));
|
super(values, candidates, strict, EpisodeMetrics.defaultSequence(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
|
|
||||||
package net.filebot.similarity;
|
|
||||||
|
|
||||||
|
|
||||||
import static java.lang.Math.*;
|
|
||||||
|
|
||||||
|
|
||||||
public enum StrictEpisodeMetrics implements SimilarityMetric {
|
|
||||||
|
|
||||||
FileName(EpisodeMetrics.FileName, 1), // only allow 0 or 1
|
|
||||||
EpisodeIdentifier(EpisodeMetrics.EpisodeIdentifier, 1), // only allow 0 or 1
|
|
||||||
SubstringFields(EpisodeMetrics.SubstringFields, 2), // allow 0 or .5 or 1
|
|
||||||
Name(EpisodeMetrics.Name, 2); // allow 0 or .5 or 1
|
|
||||||
|
|
||||||
// inner metric
|
|
||||||
private final SimilarityMetric metric;
|
|
||||||
private final float floorFactor;
|
|
||||||
|
|
||||||
|
|
||||||
private StrictEpisodeMetrics(SimilarityMetric metric, float floorFactor) {
|
|
||||||
this.metric = metric;
|
|
||||||
this.floorFactor = floorFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
|
||||||
return (float) (floor(metric.getSimilarity(o1, o2) * floorFactor) / floorFactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static SimilarityMetric[] defaultSequence(boolean includeFileMetrics) {
|
|
||||||
// use SEI for matching and SN for excluding false positives
|
|
||||||
if (includeFileMetrics) {
|
|
||||||
return new SimilarityMetric[] { FileName, EpisodeIdentifier, SubstringFields, Name };
|
|
||||||
} else {
|
|
||||||
return new SimilarityMetric[] { EpisodeIdentifier, SubstringFields, Name };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -39,7 +39,6 @@ import net.filebot.Analytics;
|
||||||
import net.filebot.Settings;
|
import net.filebot.Settings;
|
||||||
import net.filebot.similarity.CommonSequenceMatcher;
|
import net.filebot.similarity.CommonSequenceMatcher;
|
||||||
import net.filebot.similarity.EpisodeMatcher;
|
import net.filebot.similarity.EpisodeMatcher;
|
||||||
import net.filebot.similarity.EpisodeMetrics;
|
|
||||||
import net.filebot.similarity.Match;
|
import net.filebot.similarity.Match;
|
||||||
import net.filebot.ui.SelectDialog;
|
import net.filebot.ui.SelectDialog;
|
||||||
import net.filebot.web.Episode;
|
import net.filebot.web.Episode;
|
||||||
|
@ -193,7 +192,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
if (strict) {
|
if (strict) {
|
||||||
// in strict mode simply process file-by-file (ignoring all files that don't contain clear SxE patterns)
|
// in strict mode simply process file-by-file (ignoring all files that don't contain clear SxE patterns)
|
||||||
for (final File file : mediaFiles) {
|
for (final File file : mediaFiles) {
|
||||||
if (parseEpisodeNumber(file, true) != null || parseDate(file) != null) {
|
if (parseEpisodeNumber(file, false) != null || parseDate(file) != null) {
|
||||||
tasks.add(new Callable<List<Match<File, ?>>>() {
|
tasks.add(new Callable<List<Match<File, ?>>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -321,7 +320,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
EpisodeMatcher matcher = new EpisodeMatcher(filesPerType, episodes, strict);
|
EpisodeMatcher matcher = new EpisodeMatcher(filesPerType, episodes, strict);
|
||||||
for (Match<File, Object> it : matcher.match()) {
|
for (Match<File, Object> it : matcher.match()) {
|
||||||
// in strict mode sanity check the result and only pass back good matches
|
// in strict mode sanity check the result and only pass back good matches
|
||||||
if (!strict || EpisodeMetrics.EpisodeIdentifier.getSimilarity(it.getValue(), it.getCandidate()) >= 1) {
|
if (!strict || isEpisodeNumberMatch(it.getValue(), (Episode) it.getCandidate())) {
|
||||||
matches.add(new Match<File, Episode>(it.getValue(), ((Episode) it.getCandidate()).clone()));
|
matches.add(new Match<File, Episode>(it.getValue(), ((Episode) it.getCandidate()).clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue