* better movie probing

This commit is contained in:
Reinhard Pointner 2013-04-13 06:35:32 +00:00
parent fc8f6bc7ef
commit 17d1b6c4af
2 changed files with 13 additions and 10 deletions

View File

@ -632,7 +632,7 @@ public class MediaDetection {
File f = movieFile; File f = movieFile;
// check for double nested structures // check for double nested structures
if (checkMovie(f.getParentFile()) != null && checkMovie(f) == null) { if (checkMovie(f.getParentFile(), false) != null && checkMovie(f, false) == null) {
return f.getParentFile(); return f.getParentFile();
} else { } else {
return f; return f;
@ -640,20 +640,23 @@ public class MediaDetection {
} }
// first parent folder that matches a movie (max 3 levels deep) // first parent folder that matches a movie (max 3 levels deep)
File f = movieFile.getParentFile(); for (boolean strictness : new boolean[] { true, false }) {
for (int i = 0; f != null && i < 3; f = f.getParentFile(), i++) { File f = movieFile.getParentFile();
String term = stripReleaseInfo(f.getName()); for (int i = 0; f != null && i < 3; f = f.getParentFile(), i++) {
if (term.length() > 0 && checkMovie(f) != null) { String term = stripReleaseInfo(f.getName());
return f; if (term.length() > 0 && checkMovie(f, strictness) != null) {
return f;
}
} }
} }
// otherwise try the first potentially meaningful parent folder (max 2 levels deep) // otherwise try the first potentially meaningful parent folder (max 2 levels deep)
File f = movieFile.getParentFile();
for (int i = 0; f != null && i < 2; f = f.getParentFile(), i++) { for (int i = 0; f != null && i < 2; f = f.getParentFile(), i++) {
String term = stripReleaseInfo(f.getName()); String term = stripReleaseInfo(f.getName());
if (term.length() > 0) { if (term.length() > 0) {
// check for double nested structures // check for double nested structures
if (checkMovie(f.getParentFile()) != null && checkMovie(f) == null) { if (checkMovie(f.getParentFile(), false) != null && checkMovie(f, false) == null) {
return f.getParentFile(); return f.getParentFile();
} else { } else {
return f; return f;
@ -668,8 +671,8 @@ public class MediaDetection {
} }
public static Movie checkMovie(File file) throws Exception { public static Movie checkMovie(File file, boolean strict) throws Exception {
List<Movie> matches = file != null ? matchMovieName(singleton(file.getName()), false, 4) : null; List<Movie> matches = file != null ? matchMovieName(singleton(file.getName()), strict, 4) : null;
return matches != null && matches.size() > 0 ? matches.get(0) : null; return matches != null && matches.size() > 0 ? matches.get(0) : null;
} }

View File

@ -294,7 +294,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
// try to redeem possible false negative matches // try to redeem possible false negative matches
if (name.length() < 2) { if (name.length() < 2) {
Movie match = checkMovie(file); Movie match = checkMovie(file, false);
if (match != null) { if (match != null) {
return match.getName(); return match.getName();
} }