1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 16:58:51 -05:00

added constant MediaTypes.NFO_FILES file filter

This commit is contained in:
Reinhard Pointner 2012-07-26 03:33:44 +00:00
parent 6fdf3170b4
commit 9ac886f214
3 changed files with 8 additions and 10 deletions

View File

@ -13,11 +13,11 @@ import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilderFactory;
import net.sourceforge.tuned.FileUtilities.ExtensionFileFilter;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import net.sourceforge.tuned.FileUtilities.ExtensionFileFilter;
public class MediaTypes {
@ -44,7 +44,6 @@ public class MediaTypes {
}
}
private Map<String, List<String>> types;
private Map<String, ExtensionFileFilter> filters = synchronizedMap(new HashMap<String, ExtensionFileFilter>());
@ -88,9 +87,9 @@ public class MediaTypes {
return defaultInstance.getFilter(name);
}
// some convenience filters
public static final ExtensionFileFilter AUDIO_FILES = getDefaultFilter("audio");
public static final ExtensionFileFilter VIDEO_FILES = getDefaultFilter("video");
public static final ExtensionFileFilter SUBTITLE_FILES = getDefaultFilter("subtitle");
public static final ExtensionFileFilter NFO_FILES = getDefaultFilter("application/nfo");
}

View File

@ -4,6 +4,7 @@ package net.sourceforge.filebot.media;
import static java.util.Collections.*;
import static java.util.regex.Pattern.*;
import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.similarity.CommonSequenceMatcher.*;
import static net.sourceforge.filebot.similarity.Normalization.*;
import static net.sourceforge.tuned.FileUtilities.*;
@ -36,7 +37,6 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.filebot.MediaTypes;
import net.sourceforge.filebot.WebServices;
import net.sourceforge.filebot.similarity.CommonSequenceMatcher;
import net.sourceforge.filebot.similarity.DateMatcher;
@ -567,7 +567,7 @@ public class MediaDetection {
public static Set<Integer> grepImdbIdFor(File file) throws Exception {
Set<Integer> collection = new LinkedHashSet<Integer>();
if (file.exists()) {
for (File nfo : file.getParentFile().listFiles(MediaTypes.getDefaultFilter("application/nfo"))) {
for (File nfo : file.getParentFile().listFiles(NFO_FILES)) {
String text = new String(readFile(nfo), "UTF-8");
collection.addAll(grepImdbId(text));
}
@ -584,7 +584,7 @@ public class MediaDetection {
if (!folder.exists())
continue;
for (File nfo : folder.listFiles(MediaTypes.getDefaultFilter("application/nfo"))) {
for (File nfo : folder.listFiles(NFO_FILES)) {
String text = new String(readFile(nfo), "UTF-8");
for (int imdbid : grepImdbId(text)) {

View File

@ -45,7 +45,6 @@ import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import net.sourceforge.filebot.Analytics;
import net.sourceforge.filebot.MediaTypes;
import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.similarity.Match;
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
@ -75,7 +74,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
// handle movie files
Set<File> movieFiles = new TreeSet<File>(filter(fileset, VIDEO_FILES));
Set<File> nfoFiles = new TreeSet<File>(filter(fileset, MediaTypes.getDefaultFilter("application/nfo")));
Set<File> nfoFiles = new TreeSet<File>(filter(fileset, NFO_FILES));
List<File> orphanedFiles = new ArrayList<File>(filter(fileset, FILES));
orphanedFiles.removeAll(movieFiles);
@ -112,7 +111,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
// collect useful nfo files even if they are not part of the selected fileset
Set<File> effectiveNfoFileSet = new TreeSet<File>(nfoFiles);
for (File dir : mapByFolder(movieFiles).keySet()) {
addAll(effectiveNfoFileSet, dir.listFiles(MediaTypes.getDefaultFilter("application/nfo")));
addAll(effectiveNfoFileSet, dir.listFiles(NFO_FILES));
}
for (File nfo : effectiveNfoFileSet) {
try {