can't initialize with known options because misleading NFO files may lead to bad matches
This commit is contained in:
parent
dedc9c9699
commit
a6e44febfd
|
@ -586,21 +586,20 @@ public class MediaDetection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// search by file name or folder name (initialize with known options)
|
// search by file name or folder name (NOTE: can't initialize with known options because misleading NFO files may lead to bad matches)
|
||||||
Set<String> terms = options.stream().map(Movie::getNameWithYear).collect(toCollection(LinkedHashSet::new));
|
List<String> names = new ArrayList<String>(2);
|
||||||
|
|
||||||
// 1. term: try to match movie pattern 'name (year)' or use filename as is
|
// 1. term: try to match movie pattern 'name (year)' or use filename as is
|
||||||
terms.add(getName(movieFile));
|
names.add(getName(movieFile));
|
||||||
|
|
||||||
// 2. term: first meaningful parent folder
|
// 2. term: first meaningful parent folder
|
||||||
File movieFolder = guessMovieFolder(movieFile);
|
File movieFolder = guessMovieFolder(movieFile);
|
||||||
if (movieFolder != null) {
|
if (movieFolder != null) {
|
||||||
terms.add(getName(movieFolder));
|
names.add(getName(movieFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
// reduce movie names
|
// reduce movie names
|
||||||
terms = new LinkedHashSet<String>(reduceMovieNamePermutations(terms));
|
Set<String> terms = reduceMovieNamePermutations(names);
|
||||||
|
|
||||||
List<Movie> movieNameMatches = matchMovieName(terms, true, 0);
|
List<Movie> movieNameMatches = matchMovieName(terms, true, 0);
|
||||||
|
|
||||||
// skip further queries if collected matches are already sufficient
|
// skip further queries if collected matches are already sufficient
|
||||||
|
@ -753,7 +752,7 @@ public class MediaDetection {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> reduceMovieNamePermutations(Collection<String> terms) throws IOException {
|
public static Set<String> reduceMovieNamePermutations(Collection<String> terms) throws IOException {
|
||||||
LinkedList<String> names = new LinkedList<String>();
|
LinkedList<String> names = new LinkedList<String>();
|
||||||
|
|
||||||
for (String it : terms) {
|
for (String it : terms) {
|
||||||
|
@ -769,7 +768,7 @@ public class MediaDetection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return names;
|
return new LinkedHashSet<String>(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File guessMovieFolder(File movieFile) throws Exception {
|
public static File guessMovieFolder(File movieFile) throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue