* auto-match to nfo information if nfo/movie file names match
This commit is contained in:
parent
e654be95a5
commit
e89b7fbe5c
|
@ -71,6 +71,7 @@ import net.sourceforge.filebot.web.SortOrder;
|
|||
import net.sourceforge.filebot.web.SubtitleDescriptor;
|
||||
import net.sourceforge.filebot.web.SubtitleProvider;
|
||||
import net.sourceforge.filebot.web.VideoHashSubtitleService;
|
||||
import net.sourceforge.tuned.FileUtilities.FolderFilter;
|
||||
|
||||
|
||||
public class CmdlineOperations implements CmdlineInterface {
|
||||
|
@ -304,7 +305,16 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||
}
|
||||
for (File nfo : nfoFiles) {
|
||||
try {
|
||||
movieByFile.put(nfo, grepMovie(nfo, service, locale));
|
||||
Movie movie = grepMovie(nfo, service, locale);
|
||||
movieByFile.put(nfo, movie);
|
||||
|
||||
// match movie info to movie files that match the nfo file name
|
||||
SortedSet<File> siblingMovieFiles = new TreeSet<File>(filter(movieFiles, new FolderFilter(nfo.getParentFile())));
|
||||
for (File movieFile : siblingMovieFiles) {
|
||||
if (isDerived(movieFile, nfo)) {
|
||||
movieByFile.put(movieFile, movie);
|
||||
}
|
||||
}
|
||||
} catch (NoSuchElementException e) {
|
||||
CLILogger.warning("Failed to grep IMDbID: " + nfo.getName());
|
||||
}
|
||||
|
@ -317,16 +327,16 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||
movieByFile.put(file, result);
|
||||
}
|
||||
}
|
||||
// map movies to (possibly multiple) files (in natural order)
|
||||
Map<Movie, SortedSet<File>> filesByMovie = new HashMap<Movie, SortedSet<File>>();
|
||||
|
||||
// collect files that will be matched one by one
|
||||
List<File> movieMatchFiles = new ArrayList<File>();
|
||||
movieMatchFiles.addAll(movieFiles);
|
||||
movieMatchFiles.addAll(nfoFiles);
|
||||
movieMatchFiles.addAll(filter(files, new ReleaseInfo().getDiskFolderFilter()));
|
||||
movieMatchFiles.addAll(filter(orphanedFiles, SUBTITLE_FILES)); // run movie detection only on orphaned subtitle files
|
||||
|
||||
// map movies to (possibly multiple) files (in natural order)
|
||||
Map<Movie, SortedSet<File>> filesByMovie = new HashMap<Movie, SortedSet<File>>();
|
||||
|
||||
// map all files by movie
|
||||
for (final File file : movieMatchFiles) {
|
||||
Movie movie = movieByFile.get(file);
|
||||
|
|
|
@ -48,6 +48,7 @@ import net.sourceforge.filebot.web.Movie;
|
|||
import net.sourceforge.filebot.web.MovieIdentificationService;
|
||||
import net.sourceforge.filebot.web.MoviePart;
|
||||
import net.sourceforge.filebot.web.SortOrder;
|
||||
import net.sourceforge.tuned.FileUtilities.FolderFilter;
|
||||
|
||||
|
||||
class MovieHashMatcher implements AutoCompleteMatcher {
|
||||
|
@ -99,21 +100,31 @@ class MovieHashMatcher implements AutoCompleteMatcher {
|
|||
}
|
||||
for (File nfo : nfoFiles) {
|
||||
try {
|
||||
movieByFile.put(nfo, grepMovie(nfo, service, locale));
|
||||
Movie movie = grepMovie(nfo, service, locale);
|
||||
movieByFile.put(nfo, movie);
|
||||
|
||||
// match movie info to movie files that match the nfo file name
|
||||
SortedSet<File> siblingMovieFiles = new TreeSet<File>(filter(movieFiles, new FolderFilter(nfo.getParentFile())));
|
||||
for (File movieFile : siblingMovieFiles) {
|
||||
if (isDerived(movieFile, nfo)) {
|
||||
movieByFile.put(movieFile, movie);
|
||||
}
|
||||
}
|
||||
} catch (NoSuchElementException e) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Failed to grep IMDbID: " + nfo.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// match remaining movies file by file in parallel
|
||||
List<Callable<Entry<File, Movie>>> grabMovieJobs = new ArrayList<Callable<Entry<File, Movie>>>();
|
||||
|
||||
// collect files that will be matched one by one
|
||||
List<File> movieMatchFiles = new ArrayList<File>();
|
||||
movieMatchFiles.addAll(movieFiles);
|
||||
movieMatchFiles.addAll(nfoFiles);
|
||||
movieMatchFiles.addAll(filter(files, new ReleaseInfo().getDiskFolderFilter()));
|
||||
movieMatchFiles.addAll(filter(orphanedFiles, SUBTITLE_FILES)); // run movie detection only on orphaned subtitle files
|
||||
|
||||
// match remaining movies file by file in parallel
|
||||
List<Callable<Entry<File, Movie>>> grabMovieJobs = new ArrayList<Callable<Entry<File, Movie>>>();
|
||||
|
||||
// map all files by movie
|
||||
for (final File file : movieMatchFiles) {
|
||||
grabMovieJobs.add(new Callable<Entry<File, Movie>>() {
|
||||
|
|
|
@ -538,6 +538,23 @@ public final class FileUtilities {
|
|||
};
|
||||
|
||||
|
||||
public static class FolderFilter implements FileFilter {
|
||||
|
||||
private final File folder;
|
||||
|
||||
|
||||
public FolderFilter(File folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return file.getParentFile().equals(folder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ExtensionFileFilter implements FileFilter {
|
||||
|
||||
private final String[] extensions;
|
||||
|
|
Loading…
Reference in New Issue