From c981cba2e2394bc50a6cdc9c80b8cf24a57cf061 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 24 Jan 2014 17:31:33 +0000 Subject: [PATCH] * fix some GUI movie auto-selection issues --- BuildData.groovy | 6 +++--- .../sourceforge/filebot/cli/ScriptShell.lib.groovy | 3 ++- .../filebot/ui/rename/MovieHashMatcher.java | 12 +++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/BuildData.groovy b/BuildData.groovy index 94a51996..e63ca272 100644 --- a/BuildData.groovy +++ b/BuildData.groovy @@ -151,8 +151,8 @@ movies = tmdb.findResults{ movies = treeSort(movies, { it[3, 2].join(' ') }) // sanity check -pack(moviedb_out, movies*.join('\t')) if (movies.size() < 50000) { throw new Exception('Movie index sanity failed') } +pack(moviedb_out, movies*.join('\t')) /* ------------------------------------------------------------------------- */ @@ -243,8 +243,8 @@ thetvdb_index = thetvdb_index.sort({ a, b -> a[0] <=> b[0] } as Comparator) def thetvdb_txt = thetvdb_index.groupBy{ it[0] }.findResults{ k, v -> ([k.pad(6)] + v*.getAt(1).unique{ it.toLowerCase() }).join('\t') } // sanity check -pack(thetvdb_out, thetvdb_txt) if (thetvdb_txt.size() < 30000) { throw new Exception('TheTVDB index sanity failed') } +pack(thetvdb_out, thetvdb_txt) /* ------------------------------------------------------------------------- */ @@ -265,5 +265,5 @@ def anidb_index = anidb.findResults{ def anidb_txt = anidb_index.findResults{ row -> row.join('\t') }.sort().unique() // sanity check -pack(anidb_out, anidb_txt) if (anidb_txt.size() < 8000) { throw new Exception('AniDB index sanity failed') } +pack(anidb_out, anidb_txt) diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index 2a671988..76d5b9e1 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -207,7 +207,8 @@ def getRenameLog(complete = false) { import net.sourceforge.filebot.similarity.* def stripReleaseInfo(name, strict = true) { - return MediaDetection.stripReleaseInfo([name], strict)[0] + def result = MediaDetection.stripReleaseInfo([name], strict) + return result.size() > 0 ? result[0] : null } def isEpisode(path, strict = true) { diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index b57d8299..7885d01c 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -335,10 +335,20 @@ class MovieHashMatcher implements AutoCompleteMatcher { final List probableMatches = new LinkedList(); final SimilarityMetric metric = new NameSimilarityMetric(); + final float threshold = 0.9f; // find probable matches using name similarity >= 0.9 for (Movie result : options) { - if (metric.getSimilarity(fileQuery, result.getName()) >= 0.9 || metric.getSimilarity(folderQuery, result.getName()) >= 0.9) { + float maxSimilarity = 0; + for (String query : new String[] { fileQuery, folderQuery }) { + for (String name : result.getEffectiveNamesWithoutYear()) { + if (maxSimilarity >= threshold) + continue; + + maxSimilarity = Math.max(maxSimilarity, metric.getSimilarity(query, name)); + } + } + if (maxSimilarity >= threshold) { probableMatches.add(result); } }