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:
parent
6fdf3170b4
commit
9ac886f214
@ -13,11 +13,11 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import net.sourceforge.tuned.FileUtilities.ExtensionFileFilter;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
import net.sourceforge.tuned.FileUtilities.ExtensionFileFilter;
|
|
||||||
|
|
||||||
|
|
||||||
public class MediaTypes {
|
public class MediaTypes {
|
||||||
|
|
||||||
@ -44,7 +44,6 @@ public class MediaTypes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, List<String>> types;
|
private Map<String, List<String>> types;
|
||||||
private Map<String, ExtensionFileFilter> filters = synchronizedMap(new HashMap<String, ExtensionFileFilter>());
|
private Map<String, ExtensionFileFilter> filters = synchronizedMap(new HashMap<String, ExtensionFileFilter>());
|
||||||
|
|
||||||
@ -88,9 +87,9 @@ public class MediaTypes {
|
|||||||
return defaultInstance.getFilter(name);
|
return defaultInstance.getFilter(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// some convenience filters
|
// some convenience filters
|
||||||
public static final ExtensionFileFilter AUDIO_FILES = getDefaultFilter("audio");
|
public static final ExtensionFileFilter AUDIO_FILES = getDefaultFilter("audio");
|
||||||
public static final ExtensionFileFilter VIDEO_FILES = getDefaultFilter("video");
|
public static final ExtensionFileFilter VIDEO_FILES = getDefaultFilter("video");
|
||||||
public static final ExtensionFileFilter SUBTITLE_FILES = getDefaultFilter("subtitle");
|
public static final ExtensionFileFilter SUBTITLE_FILES = getDefaultFilter("subtitle");
|
||||||
|
public static final ExtensionFileFilter NFO_FILES = getDefaultFilter("application/nfo");
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package net.sourceforge.filebot.media;
|
|||||||
|
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
import static java.util.regex.Pattern.*;
|
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.CommonSequenceMatcher.*;
|
||||||
import static net.sourceforge.filebot.similarity.Normalization.*;
|
import static net.sourceforge.filebot.similarity.Normalization.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
@ -36,7 +37,6 @@ import java.util.logging.Logger;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.sourceforge.filebot.MediaTypes;
|
|
||||||
import net.sourceforge.filebot.WebServices;
|
import net.sourceforge.filebot.WebServices;
|
||||||
import net.sourceforge.filebot.similarity.CommonSequenceMatcher;
|
import net.sourceforge.filebot.similarity.CommonSequenceMatcher;
|
||||||
import net.sourceforge.filebot.similarity.DateMatcher;
|
import net.sourceforge.filebot.similarity.DateMatcher;
|
||||||
@ -567,7 +567,7 @@ public class MediaDetection {
|
|||||||
public static Set<Integer> grepImdbIdFor(File file) throws Exception {
|
public static Set<Integer> grepImdbIdFor(File file) throws Exception {
|
||||||
Set<Integer> collection = new LinkedHashSet<Integer>();
|
Set<Integer> collection = new LinkedHashSet<Integer>();
|
||||||
if (file.exists()) {
|
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");
|
String text = new String(readFile(nfo), "UTF-8");
|
||||||
collection.addAll(grepImdbId(text));
|
collection.addAll(grepImdbId(text));
|
||||||
}
|
}
|
||||||
@ -584,7 +584,7 @@ public class MediaDetection {
|
|||||||
if (!folder.exists())
|
if (!folder.exists())
|
||||||
continue;
|
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");
|
String text = new String(readFile(nfo), "UTF-8");
|
||||||
|
|
||||||
for (int imdbid : grepImdbId(text)) {
|
for (int imdbid : grepImdbId(text)) {
|
||||||
|
@ -45,7 +45,6 @@ import javax.swing.JComponent;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import net.sourceforge.filebot.Analytics;
|
import net.sourceforge.filebot.Analytics;
|
||||||
import net.sourceforge.filebot.MediaTypes;
|
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.similarity.Match;
|
import net.sourceforge.filebot.similarity.Match;
|
||||||
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
|
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
|
||||||
@ -75,7 +74,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
|
|||||||
|
|
||||||
// handle movie files
|
// handle movie files
|
||||||
Set<File> movieFiles = new TreeSet<File>(filter(fileset, VIDEO_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));
|
List<File> orphanedFiles = new ArrayList<File>(filter(fileset, FILES));
|
||||||
orphanedFiles.removeAll(movieFiles);
|
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
|
// collect useful nfo files even if they are not part of the selected fileset
|
||||||
Set<File> effectiveNfoFileSet = new TreeSet<File>(nfoFiles);
|
Set<File> effectiveNfoFileSet = new TreeSet<File>(nfoFiles);
|
||||||
for (File dir : mapByFolder(movieFiles).keySet()) {
|
for (File dir : mapByFolder(movieFiles).keySet()) {
|
||||||
addAll(effectiveNfoFileSet, dir.listFiles(MediaTypes.getDefaultFilter("application/nfo")));
|
addAll(effectiveNfoFileSet, dir.listFiles(NFO_FILES));
|
||||||
}
|
}
|
||||||
for (File nfo : effectiveNfoFileSet) {
|
for (File nfo : effectiveNfoFileSet) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user