* improve search history by using common word sequence of query and search result name
* ignore aka titles in OpenSubtitles search
This commit is contained in:
parent
b7f0529d88
commit
4346a6e05b
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<S, E> 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<S, E> 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;
|
||||
}
|
||||
|
|
|
@ -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<T> 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());
|
||||
|
|
|
@ -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<SubtitleClient, SubtitleP
|
|||
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
// add additional information to default title
|
||||
return String.format("%s [%s]", super.getTitle(), request.getLanguage().getDisplayName(Locale.ENGLISH));
|
||||
public Icon getIcon() {
|
||||
return request.client.getIcon();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -183,7 +183,16 @@ public class OpenSubtitlesClient {
|
|||
ArrayList<MovieDescriptor> movies = new ArrayList<MovieDescriptor>();
|
||||
|
||||
for (Map<String, String> 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;
|
||||
|
|
Loading…
Reference in New Issue