diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 9b1ab5fc..e509f82d 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -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 sns = new ArrayList(); + 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 diff --git a/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java b/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java index 1b1e40c8..56cd4213 100644 --- a/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java @@ -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 detectedSeriesNames = detectSeriesNames(files, locale); + String parentPathHint = normalizePathSeparators(getRelativePathTail(files.get(0).getParentFile(), 2).getPath()); + String suggestion = detectedSeriesNames.size() > 0 ? join(detectedSeriesNames, ", ") : parentPathHint; List 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); } } diff --git a/website/data/series-mappings.txt b/website/data/series-mappings.txt index 534df8ab..91ce60d9 100644 --- a/website/data/series-mappings.txt +++ b/website/data/series-mappings.txt @@ -1,3 +1,4 @@ +epl English Premier League HIMYM How I Met your Mother Hml8p Homeland hoc House of Cards