+ basic logic for hard-coding filename->series lookup (designed primarily as a workaround for database search limitations and issues)
This commit is contained in:
parent
03cb4febd1
commit
ac90b544bb
|
@ -38,6 +38,7 @@ def sortRegexList(path) {
|
|||
sortRegexList("website/data/release-groups.txt")
|
||||
sortRegexList("website/data/query-blacklist.txt")
|
||||
sortRegexList("website/data/exclude-blacklist.txt")
|
||||
sortRegexList("website/data/series-mappings.txt")
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
|
|
@ -229,6 +229,7 @@ public class MediaDetection {
|
|||
public static List<String> detectSeriesNames(Collection<File> files, Locale locale) throws Exception {
|
||||
List<String> names = new ArrayList<String>();
|
||||
|
||||
// try to detect series name via nfo files
|
||||
try {
|
||||
for (SearchResult it : lookupSeriesNameByInfoFile(files, locale)) {
|
||||
names.add(it.getName());
|
||||
|
@ -237,6 +238,13 @@ public class MediaDetection {
|
|||
Logger.getLogger(MediaDetection.class.getClass().getName()).log(Level.WARNING, "Failed to lookup info by id: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
// try to detect series name via known patterns
|
||||
try {
|
||||
names.addAll(matchSeriesByDirectMapping(files));
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(MediaDetection.class.getClass().getName()).log(Level.WARNING, "Failed to match direct mappings: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
// cross-reference known series names against file structure
|
||||
try {
|
||||
Set<String> folders = new LinkedHashSet<String>();
|
||||
|
@ -284,6 +292,22 @@ public class MediaDetection {
|
|||
}
|
||||
|
||||
|
||||
public static List<String> matchSeriesByDirectMapping(Collection<File> files) throws Exception {
|
||||
Map<Pattern, String> seriesDirectMappings = releaseInfo.getSeriesDirectMappings();
|
||||
List<String> matches = new ArrayList<String>();
|
||||
|
||||
for (File file : files) {
|
||||
for (Entry<Pattern, String> it : seriesDirectMappings.entrySet()) {
|
||||
if (it.getKey().matcher(getName(file)).find()) {
|
||||
matches.add(it.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
|
||||
public static List<String> matchSeriesByName(Collection<String> names, int maxStartIndex) throws Exception {
|
||||
HighPerformanceMatcher nameMatcher = new HighPerformanceMatcher(maxStartIndex);
|
||||
List<String> matches = new ArrayList<String>();
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Collection;
|
|||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -241,6 +242,18 @@ public class ReleaseInfo {
|
|||
}
|
||||
|
||||
|
||||
public Map<Pattern, String> getSeriesDirectMappings() throws IOException {
|
||||
Map<Pattern, String> mappings = new LinkedHashMap<Pattern, String>();
|
||||
for (String line : seriesDirectMappingsResource.get()) {
|
||||
String[] tsv = line.split("\t", 2);
|
||||
if (tsv.length == 2) {
|
||||
mappings.put(compile("(?<!\\p{Alnum})(" + tsv[0] + ")(?!\\p{Alnum})", CASE_INSENSITIVE | UNICODE_CASE), tsv[1]);
|
||||
}
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
|
||||
public FileFilter getDiskFolderFilter() {
|
||||
return new FolderEntryFilter(compile(getBundle(getClass().getName()).getString("pattern.diskfolder.entry")));
|
||||
}
|
||||
|
@ -256,6 +269,7 @@ public class ReleaseInfo {
|
|||
protected final CachedResource<String[]> excludeBlacklistResource = new PatternResource(getBundle(getClass().getName()).getString("url.exclude-blacklist"));
|
||||
protected final CachedResource<Movie[]> movieListResource = new MovieResource(getBundle(getClass().getName()).getString("url.movie-list"));
|
||||
protected final CachedResource<String[]> seriesListResource = new SeriesResource(getBundle(getClass().getName()).getString("url.series-list"));
|
||||
protected final CachedResource<String[]> seriesDirectMappingsResource = new PatternResource(getBundle(getClass().getName()).getString("url.series-mappings"));
|
||||
|
||||
|
||||
protected static class PatternResource extends CachedResource<String[]> {
|
||||
|
|
|
@ -13,6 +13,9 @@ url.query-blacklist: http://filebot.sourceforge.net/data/query-blacklist.txt
|
|||
# clutter files that will be ignored
|
||||
url.exclude-blacklist: http://filebot.sourceforge.net/data/exclude-blacklist.txt
|
||||
|
||||
# list of patterns directly matching files to series names
|
||||
url.series-mappings: http://filebot.sourceforge.net/data/series-mappings.txt
|
||||
|
||||
# list of all movies (id, name, year)
|
||||
url.movie-list: http://filebot.sourceforge.net/data/movies.txt.gz
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Franklin.and.Bash Franklin & Bash
|
||||
HIMYM How I Met your Mother
|
||||
Rizolli.and.Isles Rizzoli & Isles
|
Loading…
Reference in New Issue