* slight refactoring

This commit is contained in:
Reinhard Pointner 2014-01-08 10:01:37 +00:00
parent a920dc59a7
commit af0f4892f7
5 changed files with 8 additions and 12 deletions

View File

@ -167,7 +167,7 @@ public class CmdlineOperations implements CmdlineInterface {
// auto-detect series name if not given
if (query == null) {
// detect series name by common word sequence
seriesNames = detectSeriesNames(batch, locale, db != AniDB, db == AniDB);
seriesNames = detectSeriesNames(batch, db != AniDB, db == AniDB, locale);
CLILogger.config("Auto-detected query: " + seriesNames);
} else {
// use --q option
@ -686,7 +686,7 @@ public class CmdlineOperations implements CmdlineInterface {
if (query == null) {
try {
List<File> videoFiles = filter(files, VIDEO_FILES);
querySet.addAll(detectSeriesNames(videoFiles, language.getLocale(), true, false));
querySet.addAll(detectSeriesNames(videoFiles, true, false, language.getLocale()));
// auto-detect movie names
for (File f : videoFiles) {

View File

@ -229,8 +229,8 @@ def parseDate(path) {
return MediaDetection.parseDate(input)
}
def detectSeriesName(files, locale = Locale.ENGLISH) {
def names = MediaDetection.detectSeriesNames(files instanceof Collection ? files : [files as File], locale)
def detectSeriesName(files, boolean useSeriesIndex = true, boolean useAnimeIndex = false, Locale locale = Locale.ENGLISH) {
def names = MediaDetection.detectSeriesNames(files instanceof Collection ? files : [files as File], useSeriesIndex, useAnimeIndex, locale)
return names == null || names.isEmpty() ? null : names.toList()[0]
}

View File

@ -141,7 +141,7 @@ public class MediaDetection {
for (Entry<File, List<File>> it : filesByFolder.entrySet()) {
Set<String> namesForFolder = new TreeSet<String>(getLenientCollator(locale));
namesForFolder.addAll(detectSeriesNames(it.getValue(), locale, useSeriesIndex, useAnimeIndex));
namesForFolder.addAll(detectSeriesNames(it.getValue(), useSeriesIndex, useAnimeIndex, locale));
seriesNamesByFolder.put(it.getKey(), namesForFolder);
}
@ -270,11 +270,7 @@ public class MediaDetection {
return match;
}
public static List<String> detectSeriesNames(Collection<File> files, Locale locale) throws Exception {
return detectSeriesNames(files, locale, true, true);
}
public static List<String> detectSeriesNames(Collection<File> files, Locale locale, boolean useSeriesIndex, boolean useAnimeIndex) throws Exception {
public static List<String> detectSeriesNames(Collection<File> files, boolean useSeriesIndex, boolean useAnimeIndex, Locale locale) throws Exception {
List<IndexEntry<SearchResult>> index = new ArrayList<IndexEntry<SearchResult>>();
if (useSeriesIndex)
index.addAll(getSeriesIndex());

View File

@ -270,7 +270,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
// require user input if auto-detection has failed or has been disabled
if (episodes.isEmpty()) {
List<String> detectedSeriesNames = detectSeriesNames(files, locale, useSeriesIndex, useAnimeIndex);
List<String> detectedSeriesNames = detectSeriesNames(files, useSeriesIndex, useAnimeIndex, locale);
String parentPathHint = normalizePathSeparators(getRelativePathTail(files.get(0).getParentFile(), 2).getPath());
String suggestion = detectedSeriesNames.size() > 0 ? join(detectedSeriesNames, ", ") : parentPathHint;

View File

@ -935,7 +935,7 @@ class SubtitleAutoMatchDialog extends JDialog {
Collection<String> querySet = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
// auto-detect series names
querySet.addAll(detectSeriesNames(files, Locale.ROOT, true, false));
querySet.addAll(detectSeriesNames(files, true, false, Locale.ROOT));
// auto-detect movie names
for (File f : files) {