From 34b4630f685f5869544774bc1863ab8813f9b2c0 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 7 Dec 2011 06:33:14 +0000 Subject: [PATCH] * better detect subtitles linked to movie files --- source/net/sourceforge/filebot/cli/CmdlineOperations.java | 6 ++---- .../net/sourceforge/filebot/ui/rename/MovieHashMatcher.java | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/CmdlineOperations.java b/source/net/sourceforge/filebot/cli/CmdlineOperations.java index ffe8ba2d..f79a1935 100644 --- a/source/net/sourceforge/filebot/cli/CmdlineOperations.java +++ b/source/net/sourceforge/filebot/cli/CmdlineOperations.java @@ -257,6 +257,7 @@ public class CmdlineOperations implements CmdlineInterface { // allow subtitles without video files movieDescriptors = new Movie[subtitleFiles.length]; movieFiles = subtitleFiles; + subtitleFiles = new File[0]; } // fill in movie information from nfo file imdb when necessary @@ -306,10 +307,7 @@ public class CmdlineOperations implements CmdlineInterface { // check if subtitle corresponds to a movie file (same name, different extension) for (int i = 0; i < movieDescriptors.length; i++) { if (movieDescriptors != null) { - String subtitleName = getName(subtitleFile); - String movieName = getName(movieFiles[i]); - - if (subtitleName.equalsIgnoreCase(movieName)) { + if (isDerived(subtitleFile, movieFiles[i])) { File movieDestination = renameMap.get(movieFiles[i]); File subtitleDestination = new File(movieDestination.getParentFile(), getName(movieDestination) + "." + getExtension(subtitleFile)); renameMap.put(subtitleFile, subtitleDestination); diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index ebbeb8db..b8d89f6c 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -111,10 +111,7 @@ class MovieHashMatcher implements AutoCompleteMatcher { for (File subtitle : filter(files, SUBTITLE_FILES)) { // check if subtitle corresponds to a movie file (same name, different extension) for (Match movieMatch : matches) { - String subtitleName = getName(subtitle); - String movieName = getName(movieMatch.getValue()); - - if (subtitleName.equalsIgnoreCase(movieName)) { + if (isDerived(getName(subtitle), movieMatch.getValue())) { matches.add(new Match(subtitle, movieMatch.getCandidate())); // movie match found, we're done break;