* improved series detection

e.g.
spincity/season5/01-episodename love in it
This commit is contained in:
Reinhard Pointner 2013-04-18 09:15:58 +00:00
parent 2e71d710e3
commit 444ddd8883
3 changed files with 18 additions and 27 deletions

View File

@ -2,7 +2,6 @@
package net.sourceforge.filebot.media;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.util.regex.Pattern.*;
import static net.sourceforge.filebot.MediaTypes.*;
@ -298,26 +297,26 @@ public class MediaDetection {
matches.addAll(matchSeriesByName(stripReleaseInfo(filenames, false), 0));
}
// use lenient sub sequence matching only as fallback
if (matches.isEmpty()) {
matches.addAll(matchSeriesByName(folders, 3));
matches.addAll(matchSeriesByName(filenames, 3));
}
// assume name without spacing will mess up any lookup
// use lenient sub sequence matching only as fallback and try name without spacing logic that may mess up any lookup
if (matches.isEmpty()) {
// try to narrow down file to series name as best as possible
SeriesNameMatcher snm = new SeriesNameMatcher();
String[] sns = filenames.toArray(new String[0]);
for (int i = 0; i < sns.length; i++) {
String sn = snm.matchByEpisodeIdentifier(sns[i]);
List<String> sns = new ArrayList<String>();
sns.addAll(folders);
sns.addAll(filenames);
for (int i = 0; i < sns.size(); i++) {
String sn = snm.matchByEpisodeIdentifier(sns.get(i));
if (sn != null) {
sns[i] = sn;
sns.set(i, sn);
}
}
for (SearchResult it : matchSeriesFromStringWithoutSpacing(stripReleaseInfo(asList(sns), false), true)) {
for (SearchResult it : matchSeriesFromStringWithoutSpacing(stripReleaseInfo(sns, false), true)) {
matches.add(it.getName());
}
// less reliable CWS deep matching
matches.addAll(matchSeriesByName(folders, 2));
matches.addAll(matchSeriesByName(filenames, 2));
}
// pass along only valid terms

View File

@ -8,6 +8,7 @@ import static net.sourceforge.filebot.Settings.*;
import static net.sourceforge.filebot.media.MediaDetection.*;
import static net.sourceforge.filebot.similarity.Normalization.*;
import static net.sourceforge.tuned.FileUtilities.*;
import static net.sourceforge.tuned.StringUtilities.*;
import static net.sourceforge.tuned.ui.TunedUtilities.*;
import java.awt.Component;
@ -44,7 +45,6 @@ import net.sourceforge.filebot.similarity.CommonSequenceMatcher;
import net.sourceforge.filebot.similarity.EpisodeMatcher;
import net.sourceforge.filebot.similarity.Match;
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
import net.sourceforge.filebot.similarity.SimilarityMetric;
import net.sourceforge.filebot.ui.SelectDialog;
import net.sourceforge.filebot.web.Episode;
@ -285,24 +285,15 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
// require user input if auto-detection has failed or has been disabled
if (episodes.isEmpty()) {
String suggestion = new SeriesNameMatcher(locale).matchByEpisodeIdentifier(getName(files.get(0)));
if (suggestion != null) {
// clean media info / release group info / etc
try {
suggestion = stripReleaseInfo(suggestion);
} catch (Exception e) {
// ignore
}
} else {
// use folder name
suggestion = files.get(0).getParentFile().getName();
}
List<String> detectedSeriesNames = detectSeriesNames(files, locale);
String parentPathHint = normalizePathSeparators(getRelativePathTail(files.get(0).getParentFile(), 2).getPath());
String suggestion = detectedSeriesNames.size() > 0 ? join(detectedSeriesNames, ", ") : parentPathHint;
List<String> input = emptyList();
synchronized (inputMemory) {
input = inputMemory.get(suggestion);
if (input == null || suggestion == null || suggestion.isEmpty()) {
input = showMultiValueInputDialog("Enter series name:", suggestion, files.get(0).getParentFile().getName(), parent);
input = showMultiValueInputDialog("Enter series name:", suggestion, parentPathHint, parent);
inputMemory.put(suggestion, input);
}
}

View File

@ -1,3 +1,4 @@
epl English Premier League
HIMYM How I Met your Mother
Hml8p Homeland
hoc House of Cards