From 8f1b21a02bb264958605a40c84b3b53d2f1bd6ef Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 15 Nov 2012 12:24:31 +0000 Subject: [PATCH] * combine stripReleaseInfo & checkMovie to redeem false negative matches that would otherwise be ignored --- .../filebot/media/MediaDetection.java | 6 +++--- .../filebot/ui/rename/MovieHashMatcher.java | 19 +++++++++++++++++-- website/data/query-blacklist.txt | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 5eafee67..25f993e8 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -501,7 +501,7 @@ public class MediaDetection { File f = movieFile; // check for double nested structures - if (matchMovieFile(f.getParentFile()) != null && matchMovieFile(f) == null) { + if (checkMovie(f.getParentFile()) != null && checkMovie(f) == null) { return f.getParentFile(); } else { return f; @@ -514,7 +514,7 @@ public class MediaDetection { String term = stripReleaseInfo(f.getName()); if (term.length() > 0) { // check for double nested structures - if (matchMovieFile(f.getParentFile()) != null && matchMovieFile(f) == null) { + if (checkMovie(f.getParentFile()) != null && checkMovie(f) == null) { return f.getParentFile(); } else { return f; @@ -526,7 +526,7 @@ public class MediaDetection { } - private static Movie matchMovieFile(File file) throws Exception { + public static Movie checkMovie(File file) throws Exception { List matches = file != null ? matchMovieName(singleton(file.getName()), false, 0) : null; return matches != null && matches.size() > 0 ? matches.get(0) : null; } diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index 204d0dc8..c10889eb 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -289,13 +289,28 @@ class MovieHashMatcher implements AutoCompleteMatcher { } + protected String checkedStripReleaseInfo(File file) throws Exception { + String name = stripReleaseInfo(getName(file)); + + // try to redeem possible false negative matches + if (name.length() < 2) { + Movie match = checkMovie(file); + if (match != null) { + return match.getName(); + } + } + + return name; + } + + protected Movie selectMovie(final File movieFile, final Collection options, final Map memory, final Component parent) throws Exception { // 1. movie by filename - final String fileQuery = stripReleaseInfo(getName(movieFile)); + final String fileQuery = checkedStripReleaseInfo(movieFile); // 2. movie by directory final File movieFolder = guessMovieFolder(movieFile); - final String folderQuery = (movieFolder == null) ? "" : stripReleaseInfo(movieFolder.getName()); + final String folderQuery = (movieFolder == null) ? "" : checkedStripReleaseInfo(movieFolder); // auto-ignore invalid files if (fileQuery.length() < 2 && folderQuery.length() < 2) { diff --git a/website/data/query-blacklist.txt b/website/data/query-blacklist.txt index 16d7c071..8a5c2e4c 100644 --- a/website/data/query-blacklist.txt +++ b/website/data/query-blacklist.txt @@ -40,6 +40,7 @@ ^other$ ^Romance$ ^Science.Fiction$ +^Scratch$ ^Season.[0-9]+ ^Seeding$ ^Seeds$