diff --git a/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java b/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java index 683f2fa9..5ab690a4 100644 --- a/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java +++ b/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java @@ -231,9 +231,6 @@ public class SeriesNameMatcher { if (i == 0 && len == seq1.length) return seq1; - if (j == 0 && len == seq2.length) - return seq2; - return Arrays.copyOfRange(seq1, i, i + len); } } diff --git a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java index 9d66b72c..84ac554f 100644 --- a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java +++ b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java @@ -27,6 +27,7 @@ import javax.swing.SwingWorker; import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; +import net.sourceforge.filebot.similarity.SeriesNameMatcher; import net.sourceforge.filebot.web.SearchResult; import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.ui.LabelProvider; @@ -157,13 +158,13 @@ public abstract class AbstractSearchPanel extends FileBotPanel { return; } - String title = requestProcessor.getTitle(); + String historyEntry = requestProcessor.getHistoryEntry(); - if (!searchHistory.contains(title)) { - searchHistory.add(title); + if (historyEntry != null && !searchHistory.contains(historyEntry)) { + searchHistory.add(historyEntry); } - tab.setTitle(title); + tab.setTitle(requestProcessor.getTitle()); // fetch elements of the selected search result new FetchTask(requestProcessor).execute(); @@ -308,6 +309,15 @@ public abstract class AbstractSearchPanel extends FileBotPanel { } + public String getHistoryEntry() { + SeriesNameMatcher nameMatcher = new SeriesNameMatcher(); + + // the common word sequence of query and search result + // common name will maintain the exact word characters (incl. case) of the first argument + return nameMatcher.matchByFirstCommonWordSequence(searchResult.getName(), request.getSearchText()); + } + + public Icon getIcon() { return null; } diff --git a/source/net/sourceforge/filebot/ui/SelectDialog.java b/source/net/sourceforge/filebot/ui/SelectDialog.java index 9c7e8b52..f730fe62 100644 --- a/source/net/sourceforge/filebot/ui/SelectDialog.java +++ b/source/net/sourceforge/filebot/ui/SelectDialog.java @@ -17,6 +17,7 @@ import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JScrollPane; import javax.swing.KeyStroke; +import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import net.miginfocom.swing.MigLayout; @@ -40,8 +41,11 @@ public class SelectDialog extends JDialog { setDefaultCloseOperation(DISPOSE_ON_CLOSE); - // initialize list and select first element + // initialize list list = new JList(new ArrayListModel(options)); + + // select first element + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.setCellRenderer(new SelectListCellRenderer()); diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java index dee4e8db..8726bbc5 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java @@ -11,6 +11,8 @@ import java.util.Collection; import java.util.List; import java.util.Locale; +import javax.swing.Icon; + import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; import net.sourceforge.filebot.ResourceManager; @@ -162,9 +164,8 @@ public class SubtitlePanel extends AbstractSearchPanel movies = new ArrayList(); for (Map movie : response.get("data")) { - movies.add(new MovieDescriptor(movie.get("title"), new Integer(movie.get("id")))); + String title = movie.get("title"); + + // get end index of first non-aka title (aka titles are separated by Â) + int endIndex = title.indexOf('\u00C2'); + + if (endIndex > 0) { + title = title.substring(0, endIndex); + } + + movies.add(new MovieDescriptor(title, new Integer(movie.get("id")))); } return movies;