diff --git a/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java b/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java index 26315a9e..e92befcb 100644 --- a/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java +++ b/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java @@ -4,15 +4,11 @@ package net.sourceforge.filebot.similarity; import java.io.File; import java.util.Collection; -import java.util.Collections; - import net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE; public class SeasonEpisodeSimilarityMetric implements SimilarityMetric { - private final NumericSimilarityMetric fallbackMetric = new NumericSimilarityMetric(); - private final SeasonEpisodeMatcher seasonEpisodeMatcher = new SeasonEpisodeMatcher(); @@ -23,16 +19,26 @@ public class SeasonEpisodeSimilarityMetric implements SimilarityMetric { if (sxeVector1 == null || sxeVector2 == null) { // name does not match any known pattern, return numeric similarity - return fallbackMetric.getSimilarity(o1, o2); - } - - if (Collections.disjoint(sxeVector1, sxeVector2)) { - // vectors have no episode matches in common return 0; } - // vectors have at least one episode match in common - return 1; + float similarity = 0; + + for (SxE sxe1 : sxeVector1) { + for (SxE sxe2 : sxeVector2) { + if (sxe1.episode == sxe2.episode) { + if (sxe1.season == sxe2.season) { + // vectors have at least one perfect episode match in common + return 1; + } + + // at least we have a partial match + similarity = 0.5f; + } + } + } + + return similarity; } diff --git a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java index 7ccb82cb..fc6b078a 100644 --- a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java +++ b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java @@ -30,7 +30,6 @@ import net.sourceforge.filebot.similarity.SeriesNameMatcher; import net.sourceforge.filebot.web.SearchResult; import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.ui.LabelProvider; -import net.sourceforge.tuned.ui.SelectButtonTextField; import net.sourceforge.tuned.ui.TunedUtilities; import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.matchers.TextMatcherEditor; diff --git a/source/net/sourceforge/tuned/ui/SelectButtonTextField.java b/source/net/sourceforge/filebot/ui/SelectButtonTextField.java similarity index 97% rename from source/net/sourceforge/tuned/ui/SelectButtonTextField.java rename to source/net/sourceforge/filebot/ui/SelectButtonTextField.java index 5735d808..09797818 100644 --- a/source/net/sourceforge/tuned/ui/SelectButtonTextField.java +++ b/source/net/sourceforge/filebot/ui/SelectButtonTextField.java @@ -1,5 +1,5 @@ -package net.sourceforge.tuned.ui; +package net.sourceforge.filebot.ui; import java.awt.Component; @@ -30,6 +30,8 @@ import javax.swing.text.JTextComponent; import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; +import net.sourceforge.tuned.ui.SelectButton; +import net.sourceforge.tuned.ui.TunedUtilities; public class SelectButtonTextField extends JComponent { diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java index 115e7145..174fc1ba 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java @@ -221,10 +221,10 @@ public class RenamePanel extends FileBotPanel { model.files().addAll(remainingFiles()); } catch (Exception e) { Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e); + } finally { + // auto-match finished + namesList.firePropertyChange(LOADING_PROPERTY, true, false); } - - // auto-match finished - namesList.firePropertyChange(LOADING_PROPERTY, true, false); } @@ -234,7 +234,7 @@ public class RenamePanel extends FileBotPanel { return searchResults.iterator().next(); } - List probableMatches = new LinkedList(); + final List probableMatches = new LinkedList(); // use name similarity metric SimilarityMetric metric = new NameSimilarityMetric(); @@ -256,7 +256,7 @@ public class RenamePanel extends FileBotPanel { @Override public SearchResult call() throws Exception { // multiple results have been found, user must select one - SelectDialog selectDialog = new SelectDialog(SwingUtilities.getWindowAncestor(RenamePanel.this), searchResults); + SelectDialog selectDialog = new SelectDialog(SwingUtilities.getWindowAncestor(RenamePanel.this), probableMatches.isEmpty() ? searchResults : probableMatches); selectDialog.getHeaderLabel().setText(String.format("Shows matching '%s':", query)); diff --git a/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java b/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java index fc6cd73e..b6057f20 100644 --- a/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java +++ b/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java @@ -36,6 +36,9 @@ public class DefaultClipboardHandler implements ClipboardHandler { for (Object value : list.getSelectedValues()) { sb.append(value == null ? "" : value).append(newLine); } + + // delete last newline + sb.delete(sb.length() - newLine.length(), sb.length()); } @@ -45,6 +48,9 @@ public class DefaultClipboardHandler implements ClipboardHandler { sb.append(value == null ? "" : value).append(newLine); } + + // delete last newline + sb.delete(sb.length() - newLine.length(), sb.length()); } @@ -66,5 +72,8 @@ public class DefaultClipboardHandler implements ClipboardHandler { sb.append(newLine); } + + // delete last newline + sb.delete(sb.length() - newLine.length(), sb.length()); } }