mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 16:28:51 -05:00
Make sure that movie object localization doesn't break anything
This commit is contained in:
parent
9c3e60f34e
commit
1f6f184e8d
@ -279,7 +279,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
return validMatches;
|
||||
}
|
||||
|
||||
private List<Episode> fetchEpisodeSet(final EpisodeListProvider db, final Collection<String> names, final SortOrder sortOrder, final Locale locale, final boolean strict) throws Exception {
|
||||
private List<Episode> fetchEpisodeSet(EpisodeListProvider db, Collection<String> names, SortOrder sortOrder, Locale locale, boolean strict) throws Exception {
|
||||
Set<SearchResult> shows = new LinkedHashSet<SearchResult>();
|
||||
Set<Episode> episodes = new LinkedHashSet<Episode>();
|
||||
|
||||
@ -341,7 +341,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
}
|
||||
|
||||
// match movie hashes online
|
||||
final Map<File, Movie> movieByFile = new TreeMap<File, Movie>();
|
||||
Map<File, Movie> movieByFile = new TreeMap<File, Movie>();
|
||||
if (query == null) {
|
||||
// collect useful nfo files even if they are not part of the selected fileset
|
||||
Set<File> effectiveNfoFileSet = new TreeSet<File>(nfoFiles);
|
||||
@ -418,7 +418,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
Map<Movie, SortedSet<File>> filesByMovie = new HashMap<Movie, SortedSet<File>>();
|
||||
|
||||
// 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<FileInfo> outputMapping = new ArrayList<FileInfo>();
|
||||
List<FileInfo> outputMapping = new ArrayList<FileInfo>();
|
||||
for (FileInfo it : archive.listFiles()) {
|
||||
File outputPath = outputMapper.getOutputFile(it.toFile());
|
||||
outputMapping.add(new SimpleFileInfo(outputPath.getPath(), it.getLength()));
|
||||
}
|
||||
|
||||
final Set<FileInfo> selection = new TreeSet<FileInfo>();
|
||||
Set<FileInfo> selection = new TreeSet<FileInfo>();
|
||||
for (FileInfo future : outputMapping) {
|
||||
if (filter == null || filter.accept(future.toFile())) {
|
||||
selection.add(future);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -176,12 +176,15 @@ class MovieMatcher implements AutoCompleteMatcher {
|
||||
|
||||
for (Future<Map<File, List<Movie>>> future : tasks) {
|
||||
for (Entry<File, List<Movie>> 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<Movie> 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<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
||||
if (input != null && input.length() > 0) {
|
||||
List<Movie> results = detectMovie(new File(input), service, locale, false);
|
||||
for (Movie it : results) {
|
||||
// make sure to retrieve language-specific movie descriptor
|
||||
matches.add(new Match<File, Movie>(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<File, Movie>(null, getLocalizedMovie(service, movie, locale)));
|
||||
}
|
||||
}
|
||||
return matches;
|
||||
|
Loading…
Reference in New Issue
Block a user