diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index cda8670d..483e542f 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -279,7 +279,7 @@ public class CmdlineOperations implements CmdlineInterface { return validMatches; } - private List fetchEpisodeSet(final EpisodeListProvider db, final Collection names, final SortOrder sortOrder, final Locale locale, final boolean strict) throws Exception { + private List fetchEpisodeSet(EpisodeListProvider db, Collection names, SortOrder sortOrder, Locale locale, boolean strict) throws Exception { Set shows = new LinkedHashSet(); Set episodes = new LinkedHashSet(); @@ -341,7 +341,7 @@ public class CmdlineOperations implements CmdlineInterface { } // match movie hashes online - final Map movieByFile = new TreeMap(); + Map movieByFile = new TreeMap(); if (query == null) { // collect useful nfo files even if they are not part of the selected fileset Set effectiveNfoFileSet = new TreeSet(nfoFiles); @@ -418,7 +418,7 @@ public class CmdlineOperations implements CmdlineInterface { Map> filesByMovie = new HashMap>(); // map all files by movie - for (final File file : movieMatchFiles) { + for (File file : movieMatchFiles) { Movie movie = movieByFile.get(file); // unknown hash, try via imdb id from nfo file @@ -438,8 +438,10 @@ public class CmdlineOperations implements CmdlineInterface { try { // select first element if matches are reliable if (options.size() > 0) { + movie = (Movie) selectSearchResult(null, options, false, strict).get(0); + // make sure to get the language-specific movie object for the selected option - movie = service.getMovieDescriptor((Movie) selectSearchResult(null, options, false, strict).get(0), locale); + movie = getLocalizedMovie(service, movie, locale); } } catch (Exception e) { log.log(Level.WARNING, format("%s: [%s] %s", e.getClass().getSimpleName(), getStructurePathTail(file), e.getMessage())); @@ -1108,15 +1110,15 @@ public class CmdlineOperations implements CmdlineInterface { outputFolder = outputFolder.getCanonicalFile(); // normalize weird paths log.info(format("Read archive [%s] and extract to [%s]", file.getName(), outputFolder)); - final FileMapper outputMapper = new FileMapper(outputFolder); + FileMapper outputMapper = new FileMapper(outputFolder); - final List outputMapping = new ArrayList(); + List outputMapping = new ArrayList(); for (FileInfo it : archive.listFiles()) { File outputPath = outputMapper.getOutputFile(it.toFile()); outputMapping.add(new SimpleFileInfo(outputPath.getPath(), it.getLength())); } - final Set selection = new TreeSet(); + Set selection = new TreeSet(); for (FileInfo future : outputMapping) { if (filter == null || filter.accept(future.toFile())) { selection.add(future); diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index 3023a150..61fd1b5e 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -698,6 +698,19 @@ public class MediaDetection { }); } + public static Movie getLocalizedMovie(MovieIdentificationService service, Movie movie, Locale locale) throws Exception { + // retrieve language-specific movie object if possible + try { + Movie localized = service.getMovieDescriptor(movie, locale); + if (localized != null) { + return localized; + } + } catch (Exception e) { + debug.log(Level.WARNING, "Failed to retrieve localized movie data", e); + } + return movie; + } + public static SimilarityMetric getSeriesMatchMetric() { return new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric(), new SequenceMatchSimilarity(0, true)); } diff --git a/source/net/filebot/ui/rename/MovieMatcher.java b/source/net/filebot/ui/rename/MovieMatcher.java index bf385a0b..cc280aac 100644 --- a/source/net/filebot/ui/rename/MovieMatcher.java +++ b/source/net/filebot/ui/rename/MovieMatcher.java @@ -176,12 +176,15 @@ class MovieMatcher implements AutoCompleteMatcher { for (Future>> future : tasks) { for (Entry> it : future.get().entrySet()) { - // auto-select movie or ask user - Movie movie = grabMovieName(it.getKey(), it.getValue(), strict, locale, autodetect, parent); + File file = it.getKey(); + List options = it.getValue(); - // make sure to use language-specific movie object + // auto-select movie or ask user + Movie movie = grabMovieName(file, options, strict, locale, autodetect, parent); + + // make sure to use language-specific movie object if possible if (movie != null) { - movieByFile.put(it.getKey(), service.getMovieDescriptor(movie, locale)); + movieByFile.put(file, getLocalizedMovie(service, movie, locale)); } } } @@ -410,10 +413,9 @@ class MovieMatcher implements AutoCompleteMatcher { List> matches = new ArrayList>(); if (input != null && input.length() > 0) { - List results = detectMovie(new File(input), service, locale, false); - for (Movie it : results) { - // make sure to retrieve language-specific movie descriptor - matches.add(new Match(null, service.getMovieDescriptor(it, locale))); + for (Movie movie : detectMovie(new File(input), service, locale, false)) { + // make sure to use language-specific movie object if possible + matches.add(new Match(null, getLocalizedMovie(service, movie, locale))); } } return matches;