* infer media info bindings from just any video file if necessary

This commit is contained in:
Reinhard Pointner 2012-07-29 12:42:05 +00:00
parent 100d5c5a4f
commit f56010bcd1
3 changed files with 10 additions and 4 deletions

View File

@ -367,7 +367,7 @@ public class CmdlineOperations implements CmdlineInterface {
String baseName = stripReleaseInfo(getName(nfo)).toLowerCase();
for (File movieFile : siblingMovieFiles) {
if (stripReleaseInfo(getName(movieFile)).toLowerCase().startsWith(baseName)) {
if (!baseName.isEmpty() && stripReleaseInfo(getName(movieFile)).toLowerCase().startsWith(baseName)) {
movieByFile.put(movieFile, movie);
}
}

View File

@ -526,13 +526,19 @@ public class MediaBindingBean {
} else if (!VIDEO_FILES.accept(mediaFile)) {
// file is a subtitle, or nfo, etc
String baseName = stripReleaseInfo(FileUtilities.getName(mediaFile)).toLowerCase();
File[] videos = mediaFile.getParentFile().listFiles(VIDEO_FILES);
// find corresponding movie file
for (File movieFile : mediaFile.getParentFile().listFiles(VIDEO_FILES)) {
if (stripReleaseInfo(FileUtilities.getName(movieFile)).toLowerCase().startsWith(baseName)) {
for (File movieFile : videos) {
if (!baseName.isEmpty() && stripReleaseInfo(FileUtilities.getName(movieFile)).toLowerCase().startsWith(baseName)) {
return movieFile;
}
}
// still no good match found -> just take any video from the same folder
if (videos.length > 0) {
return videos[0];
}
}
return mediaFile;

View File

@ -144,7 +144,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
String baseName = stripReleaseInfo(getName(nfo)).toLowerCase();
for (File movieFile : siblingMovieFiles) {
if (stripReleaseInfo(getName(movieFile)).toLowerCase().startsWith(baseName)) {
if (!baseName.isEmpty() && stripReleaseInfo(getName(movieFile)).toLowerCase().startsWith(baseName)) {
movieByFile.put(movieFile, movie);
}
}