+ Support episode SortOrder
This commit is contained in:
parent
05417b1b39
commit
f2e07377ef
|
@ -28,6 +28,9 @@ public class ArgumentBean {
|
||||||
@Option(name = "--db", usage = "Episode/Movie database", metaVar = "[TVRage, AniDB, TheTVDB] or [OpenSubtitles, TheMovieDB]")
|
@Option(name = "--db", usage = "Episode/Movie database", metaVar = "[TVRage, AniDB, TheTVDB] or [OpenSubtitles, TheMovieDB]")
|
||||||
public String db;
|
public String db;
|
||||||
|
|
||||||
|
@Option(name = "--order", usage = "Episode order", metaVar = "[Default, Absolute, DVD]")
|
||||||
|
public String order = "Airdate";
|
||||||
|
|
||||||
@Option(name = "--format", usage = "Episode naming scheme", metaVar = "expression")
|
@Option(name = "--format", usage = "Episode naming scheme", metaVar = "expression")
|
||||||
public String format;
|
public String format;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ArgumentProcessor {
|
||||||
try {
|
try {
|
||||||
// print episode info
|
// print episode info
|
||||||
if (args.list) {
|
if (args.list) {
|
||||||
for (String eps : cli.fetchEpisodeList(args.query, args.format, args.db, args.lang)) {
|
for (String eps : cli.fetchEpisodeList(args.query, args.format, args.db, args.order, args.lang)) {
|
||||||
System.out.println(eps);
|
System.out.println(eps);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -69,7 +69,7 @@ public class ArgumentProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.rename) {
|
if (args.rename) {
|
||||||
cli.rename(files, args.query, args.format, args.db, args.lang, !args.nonStrict);
|
cli.rename(files, args.query, args.format, args.db, args.order, args.lang, !args.nonStrict);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.check) {
|
if (args.check) {
|
||||||
|
|
|
@ -9,24 +9,24 @@ import java.util.List;
|
||||||
|
|
||||||
public interface CmdlineInterface {
|
public interface CmdlineInterface {
|
||||||
|
|
||||||
List<File> rename(Collection<File> files, String query, String format, String db, String lang, boolean strict) throws Exception;
|
List<File> rename(Collection<File> files, String query, String format, String db, String sortOrder, String lang, boolean strict) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<File> getSubtitles(Collection<File> files, String query, String lang, String output, String encoding, boolean strict) throws Exception;
|
List<File> getSubtitles(Collection<File> files, String query, String lang, String output, String encoding, boolean strict) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
List<File> getMissingSubtitles(Collection<File> files, String query, String lang, String output, String encoding, boolean strict) throws Exception;
|
List<File> getMissingSubtitles(Collection<File> files, String query, String lang, String output, String encoding, boolean strict) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
boolean check(Collection<File> files) throws Exception;
|
boolean check(Collection<File> files) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
File compute(Collection<File> files, String output, String encoding) throws Exception;
|
File compute(Collection<File> files, String output, String encoding) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
List<String> fetchEpisodeList(String query, String format, String db, String lang) throws Exception;
|
|
||||||
|
|
||||||
|
List<String> fetchEpisodeList(String query, String format, String db, String sortOrder, String lang) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
String getMediaInfo(File file, String format) throws Exception;
|
String getMediaInfo(File file, String format) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ import net.sourceforge.filebot.web.Movie;
|
||||||
import net.sourceforge.filebot.web.MovieIdentificationService;
|
import net.sourceforge.filebot.web.MovieIdentificationService;
|
||||||
import net.sourceforge.filebot.web.MoviePart;
|
import net.sourceforge.filebot.web.MoviePart;
|
||||||
import net.sourceforge.filebot.web.SearchResult;
|
import net.sourceforge.filebot.web.SearchResult;
|
||||||
|
import net.sourceforge.filebot.web.SortOrder;
|
||||||
import net.sourceforge.filebot.web.SubtitleDescriptor;
|
import net.sourceforge.filebot.web.SubtitleDescriptor;
|
||||||
import net.sourceforge.filebot.web.SubtitleProvider;
|
import net.sourceforge.filebot.web.SubtitleProvider;
|
||||||
import net.sourceforge.filebot.web.VideoHashSubtitleService;
|
import net.sourceforge.filebot.web.VideoHashSubtitleService;
|
||||||
|
@ -74,7 +75,7 @@ import net.sourceforge.filebot.web.VideoHashSubtitleService;
|
||||||
public class CmdlineOperations implements CmdlineInterface {
|
public class CmdlineOperations implements CmdlineInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<File> rename(Collection<File> files, String query, String expression, String db, String languageName, boolean strict) throws Exception {
|
public List<File> rename(Collection<File> files, String query, String expression, String db, String sortOrder, String languageName, boolean strict) throws Exception {
|
||||||
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
||||||
Locale locale = getLanguage(languageName).toLocale();
|
Locale locale = getLanguage(languageName).toLocale();
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
|
|
||||||
if (getEpisodeListProvider(db) != null) {
|
if (getEpisodeListProvider(db) != null) {
|
||||||
// tv series mode
|
// tv series mode
|
||||||
return renameSeries(files, query, format, getEpisodeListProvider(db), locale, strict);
|
return renameSeries(files, query, format, getEpisodeListProvider(db), SortOrder.forName(sortOrder), locale, strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMovieIdentificationService(db) != null) {
|
if (getMovieIdentificationService(db) != null) {
|
||||||
|
@ -121,14 +122,14 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
|
|
||||||
CLILogger.finest(format("Filename pattern: [%.02f] SxE, [%.02f] CWS", sxe / max, cws / max));
|
CLILogger.finest(format("Filename pattern: [%.02f] SxE, [%.02f] CWS", sxe / max, cws / max));
|
||||||
if (sxe >= (max * 0.65) || cws >= (max * 0.65)) {
|
if (sxe >= (max * 0.65) || cws >= (max * 0.65)) {
|
||||||
return renameSeries(files, query, format, getEpisodeListProviders()[0], locale, strict); // use default episode db
|
return renameSeries(files, query, format, getEpisodeListProviders()[0], SortOrder.forName(sortOrder), locale, strict); // use default episode db
|
||||||
} else {
|
} else {
|
||||||
return renameMovie(files, query, format, getMovieIdentificationServices()[0], locale, strict); // use default movie db
|
return renameMovie(files, query, format, getMovieIdentificationServices()[0], locale, strict); // use default movie db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<File> renameSeries(Collection<File> files, String query, ExpressionFormat format, EpisodeListProvider db, Locale locale, boolean strict) throws Exception {
|
public List<File> renameSeries(Collection<File> files, String query, ExpressionFormat format, EpisodeListProvider db, SortOrder sortOrder, Locale locale, boolean strict) throws Exception {
|
||||||
CLILogger.config(format("Rename episodes using [%s]", db.getName()));
|
CLILogger.config(format("Rename episodes using [%s]", db.getName()));
|
||||||
List<File> mediaFiles = filter(files, VIDEO_FILES, SUBTITLE_FILES);
|
List<File> mediaFiles = filter(files, VIDEO_FILES, SUBTITLE_FILES);
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
Collection<String> seriesNames = (query == null) ? detectQuery(batch, locale, strict) : singleton(query);
|
Collection<String> seriesNames = (query == null) ? detectQuery(batch, locale, strict) : singleton(query);
|
||||||
|
|
||||||
// fetch episode data
|
// fetch episode data
|
||||||
Set<Episode> episodes = fetchEpisodeSet(db, seriesNames, locale, strict);
|
Set<Episode> episodes = fetchEpisodeSet(db, seriesNames, sortOrder, locale, strict);
|
||||||
|
|
||||||
if (episodes.size() > 0) {
|
if (episodes.size() > 0) {
|
||||||
matches.addAll(matchEpisodes(filter(mediaFiles, VIDEO_FILES), episodes, sequence));
|
matches.addAll(matchEpisodes(filter(mediaFiles, VIDEO_FILES), episodes, sequence));
|
||||||
|
@ -204,7 +205,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Set<Episode> fetchEpisodeSet(final EpisodeListProvider db, final Collection<String> names, final Locale locale, final boolean strict) throws Exception {
|
private Set<Episode> fetchEpisodeSet(final EpisodeListProvider db, final Collection<String> names, final SortOrder sortOrder, final Locale locale, final boolean strict) throws Exception {
|
||||||
List<Callable<List<Episode>>> tasks = new ArrayList<Callable<List<Episode>>>();
|
List<Callable<List<Episode>>> tasks = new ArrayList<Callable<List<Episode>>>();
|
||||||
|
|
||||||
// detect series names and create episode list fetch tasks
|
// detect series names and create episode list fetch tasks
|
||||||
|
@ -223,7 +224,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
List<Episode> episodes = new ArrayList<Episode>();
|
List<Episode> episodes = new ArrayList<Episode>();
|
||||||
for (SearchResult it : selectedSearchResults) {
|
for (SearchResult it : selectedSearchResults) {
|
||||||
CLILogger.fine(format("Fetching episode data for [%s]", it.getName()));
|
CLILogger.fine(format("Fetching episode data for [%s]", it.getName()));
|
||||||
episodes.addAll(db.getEpisodeList(it, locale));
|
episodes.addAll(db.getEpisodeList(it, sortOrder, locale));
|
||||||
Analytics.trackEvent(db.getName(), "FetchEpisodeList", it.getName());
|
Analytics.trackEvent(db.getName(), "FetchEpisodeList", it.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,16 +863,17 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> fetchEpisodeList(String query, String expression, String db, String languageName) throws Exception {
|
public List<String> fetchEpisodeList(String query, String expression, String db, String sortOrderName, String languageName) throws Exception {
|
||||||
// find series on the web and fetch episode list
|
// find series on the web and fetch episode list
|
||||||
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
||||||
EpisodeListProvider service = (db == null) ? TVRage : getEpisodeListProvider(db);
|
EpisodeListProvider service = (db == null) ? TVRage : getEpisodeListProvider(db);
|
||||||
|
SortOrder sortOrder = SortOrder.forName(sortOrderName);
|
||||||
Locale locale = getLanguage(languageName).toLocale();
|
Locale locale = getLanguage(languageName).toLocale();
|
||||||
|
|
||||||
SearchResult hit = selectSearchResult(query, service.search(query, locale), false).get(0);
|
SearchResult hit = selectSearchResult(query, service.search(query, locale), false).get(0);
|
||||||
List<String> episodes = new ArrayList<String>();
|
List<String> episodes = new ArrayList<String>();
|
||||||
|
|
||||||
for (Episode it : service.getEpisodeList(hit, locale)) {
|
for (Episode it : service.getEpisodeList(hit, sortOrder, locale)) {
|
||||||
String name = (format != null) ? format.format(new MediaBindingBean(it, null)) : EpisodeFormat.SeasonEpisode.format(it);
|
String name = (format != null) ? format.format(new MediaBindingBean(it, null)) : EpisodeFormat.SeasonEpisode.format(it);
|
||||||
episodes.add(name);
|
episodes.add(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> o
|
||||||
// CLI bindings
|
// CLI bindings
|
||||||
def rename(args) { args = _defaults(args)
|
def rename(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.lang, args.strict) }
|
_guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.order, args.lang, args.strict) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ def compute(args) { args = _defaults(args)
|
||||||
|
|
||||||
def fetchEpisodeList(args) { args = _defaults(args)
|
def fetchEpisodeList(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.fetchEpisodeList(args.query, args.format, args.db, args.lang) }
|
_guarded { _cli.fetchEpisodeList(args.query, args.format, args.db, args.order, args.lang) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,6 +244,7 @@ def _defaults(args) {
|
||||||
args.query = args.query ?: _args.query
|
args.query = args.query ?: _args.query
|
||||||
args.format = args.format ?: _args.format
|
args.format = args.format ?: _args.format
|
||||||
args.db = args.db ?: _args.db
|
args.db = args.db ?: _args.db
|
||||||
|
args.order = args.order ?: _args.order
|
||||||
args.lang = args.lang ?: _args.lang
|
args.lang = args.lang ?: _args.lang
|
||||||
args.output = args.output ?: _args.output
|
args.output = args.output ?: _args.output
|
||||||
args.encoding = args.encoding ?: _args.encoding
|
args.encoding = args.encoding ?: _args.encoding
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui.episodelist;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.ui.episodelist.SeasonSpinnerModel.*;
|
import static net.sourceforge.filebot.ui.episodelist.SeasonSpinnerModel.*;
|
||||||
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
|
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
@ -21,6 +22,7 @@ import java.util.Locale;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
@ -43,6 +45,8 @@ import net.sourceforge.filebot.ui.transfer.SaveAction;
|
||||||
import net.sourceforge.filebot.web.Episode;
|
import net.sourceforge.filebot.web.Episode;
|
||||||
import net.sourceforge.filebot.web.EpisodeListProvider;
|
import net.sourceforge.filebot.web.EpisodeListProvider;
|
||||||
import net.sourceforge.filebot.web.SearchResult;
|
import net.sourceforge.filebot.web.SearchResult;
|
||||||
|
import net.sourceforge.filebot.web.SeasonOutOfBoundsException;
|
||||||
|
import net.sourceforge.filebot.web.SortOrder;
|
||||||
import net.sourceforge.tuned.StringUtilities;
|
import net.sourceforge.tuned.StringUtilities;
|
||||||
import net.sourceforge.tuned.ui.LabelProvider;
|
import net.sourceforge.tuned.ui.LabelProvider;
|
||||||
import net.sourceforge.tuned.ui.SelectButton;
|
import net.sourceforge.tuned.ui.SelectButton;
|
||||||
|
@ -54,8 +58,9 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
|
|
||||||
private SeasonSpinnerModel seasonSpinnerModel = new SeasonSpinnerModel();
|
private SeasonSpinnerModel seasonSpinnerModel = new SeasonSpinnerModel();
|
||||||
private LanguageComboBox languageComboBox = new LanguageComboBox(this, Language.getLanguage("en"));
|
private LanguageComboBox languageComboBox = new LanguageComboBox(this, Language.getLanguage("en"));
|
||||||
|
private JComboBox sortOrderComboBox = new JComboBox(SortOrder.values());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public EpisodeListPanel() {
|
public EpisodeListPanel() {
|
||||||
historyPanel.setColumnHeader(0, "Show");
|
historyPanel.setColumnHeader(0, "Show");
|
||||||
historyPanel.setColumnHeader(1, "Number of Episodes");
|
historyPanel.setColumnHeader(1, "Number of Episodes");
|
||||||
|
@ -67,8 +72,9 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
seasonSpinner.setMinimumSize(seasonSpinner.getPreferredSize());
|
seasonSpinner.setMinimumSize(seasonSpinner.getPreferredSize());
|
||||||
|
|
||||||
// add after text field
|
// add after text field
|
||||||
add(seasonSpinner, "gap indent", 1);
|
add(seasonSpinner, "sgy combo, gap indent", 1);
|
||||||
add(languageComboBox, "gap indent+5", 2);
|
add(sortOrderComboBox, "sgy combo, gap rel", 2);
|
||||||
|
add(languageComboBox, "sgy combo, gap indent+5", 3);
|
||||||
|
|
||||||
// add after tabbed pane
|
// add after tabbed pane
|
||||||
tabbedPaneGroup.add(new JButton(new SaveAction(new SelectedTabExportHandler())));
|
tabbedPaneGroup.add(new JButton(new SaveAction(new SelectedTabExportHandler())));
|
||||||
|
@ -79,36 +85,37 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("shift DOWN"), new SpinSeasonAction(-1));
|
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("shift DOWN"), new SpinSeasonAction(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EpisodeListProvider[] getSearchEngines() {
|
protected EpisodeListProvider[] getSearchEngines() {
|
||||||
return WebServices.getEpisodeListProviders();
|
return WebServices.getEpisodeListProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LabelProvider<EpisodeListProvider> getSearchEngineLabelProvider() {
|
protected LabelProvider<EpisodeListProvider> getSearchEngineLabelProvider() {
|
||||||
return SimpleLabelProvider.forClass(EpisodeListProvider.class);
|
return SimpleLabelProvider.forClass(EpisodeListProvider.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Settings getSettings() {
|
protected Settings getSettings() {
|
||||||
return Settings.forPackage(EpisodeListPanel.class);
|
return Settings.forPackage(EpisodeListPanel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EpisodeListRequestProcessor createRequestProcessor() {
|
protected EpisodeListRequestProcessor createRequestProcessor() {
|
||||||
EpisodeListProvider provider = searchTextField.getSelectButton().getSelectedValue();
|
EpisodeListProvider provider = searchTextField.getSelectButton().getSelectedValue();
|
||||||
String text = searchTextField.getText().trim();
|
String text = searchTextField.getText().trim();
|
||||||
int season = seasonSpinnerModel.getSeason();
|
int season = seasonSpinnerModel.getSeason();
|
||||||
|
SortOrder order = (SortOrder) sortOrderComboBox.getSelectedItem();
|
||||||
Locale language = languageComboBox.getModel().getSelectedItem().toLocale();
|
Locale language = languageComboBox.getModel().getSelectedItem().toLocale();
|
||||||
|
|
||||||
return new EpisodeListRequestProcessor(new EpisodeListRequest(provider, text, season, language));
|
return new EpisodeListRequestProcessor(new EpisodeListRequest(provider, text, season, order, language));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private final PropertyChangeListener selectButtonListener = new PropertyChangeListener() {
|
private final PropertyChangeListener selectButtonListener = new PropertyChangeListener() {
|
||||||
|
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
|
@ -123,7 +130,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private class SpinSeasonAction extends AbstractAction {
|
private class SpinSeasonAction extends AbstractAction {
|
||||||
|
|
||||||
public SpinSeasonAction(int spin) {
|
public SpinSeasonAction(int spin) {
|
||||||
|
@ -131,13 +138,13 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
putValue("spin", spin);
|
putValue("spin", spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
seasonSpinnerModel.spin((Integer) getValue("spin"));
|
seasonSpinnerModel.spin((Integer) getValue("spin"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class SelectedTabExportHandler implements FileExportHandler {
|
private class SelectedTabExportHandler implements FileExportHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,7 +161,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExport() {
|
public boolean canExport() {
|
||||||
FileExportHandler handler = getExportHandler();
|
FileExportHandler handler = getExportHandler();
|
||||||
|
@ -165,13 +172,13 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
return handler.canExport();
|
return handler.canExport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void export(File file) throws IOException {
|
public void export(File file) throws IOException {
|
||||||
getExportHandler().export(file);
|
getExportHandler().export(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultFileName() {
|
public String getDefaultFileName() {
|
||||||
return getExportHandler().getDefaultFileName();
|
return getExportHandler().getDefaultFileName();
|
||||||
|
@ -179,75 +186,61 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static class EpisodeListRequest extends Request {
|
protected static class EpisodeListRequest extends Request {
|
||||||
|
|
||||||
private final EpisodeListProvider provider;
|
public final EpisodeListProvider provider;
|
||||||
private final int season;
|
public final int season;
|
||||||
private final Locale language;
|
public final SortOrder order;
|
||||||
|
public final Locale language;
|
||||||
|
|
||||||
|
|
||||||
public EpisodeListRequest(EpisodeListProvider provider, String searchText, int season, Locale language) {
|
public EpisodeListRequest(EpisodeListProvider provider, String searchText, int season, SortOrder order, Locale language) {
|
||||||
super(searchText);
|
super(searchText);
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.season = season;
|
this.season = season;
|
||||||
|
this.order = order;
|
||||||
this.language = language;
|
this.language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public EpisodeListProvider getProvider() {
|
|
||||||
return provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getSeason() {
|
|
||||||
return season;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Locale getLanguage() {
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static class EpisodeListRequestProcessor extends RequestProcessor<EpisodeListRequest, Episode> {
|
protected static class EpisodeListRequestProcessor extends RequestProcessor<EpisodeListRequest, Episode> {
|
||||||
|
|
||||||
public EpisodeListRequestProcessor(EpisodeListRequest request) {
|
public EpisodeListRequestProcessor(EpisodeListRequest request) {
|
||||||
super(request, new EpisodeListTab());
|
super(request, new EpisodeListTab());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<SearchResult> search() throws Exception {
|
public Collection<SearchResult> search() throws Exception {
|
||||||
return request.getProvider().search(request.getSearchText(), request.getLanguage());
|
return request.provider.search(request.getSearchText(), request.language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Episode> fetch() throws Exception {
|
public Collection<Episode> fetch() throws Exception {
|
||||||
List<Episode> episodes;
|
List<Episode> episodes = request.provider.getEpisodeList(getSearchResult(), request.order, request.language);
|
||||||
|
|
||||||
if (request.getSeason() != ALL_SEASONS)
|
if (request.season != ALL_SEASONS) {
|
||||||
episodes = request.getProvider().getEpisodeList(getSearchResult(), request.getSeason(), request.getLanguage());
|
List<Episode> episodeForSeason = filterBySeason(episodes, request.season);
|
||||||
else
|
if (episodeForSeason.isEmpty()) {
|
||||||
episodes = request.getProvider().getEpisodeList(getSearchResult(), request.getLanguage());
|
throw new SeasonOutOfBoundsException(getSearchResult().getName(), request.season, getLastSeason(episodes));
|
||||||
|
}
|
||||||
|
episodes = episodeForSeason;
|
||||||
|
}
|
||||||
|
|
||||||
Analytics.trackEvent(request.getProvider().getName(), "ViewEpisodeList", getSearchResult().getName());
|
Analytics.trackEvent(request.provider.getName(), "ViewEpisodeList", getSearchResult().getName());
|
||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getLink() {
|
public URI getLink() {
|
||||||
if (request.getSeason() != ALL_SEASONS) {
|
return request.provider.getEpisodeListLink(getSearchResult());
|
||||||
return request.getProvider().getEpisodeListLink(getSearchResult(), request.getSeason());
|
|
||||||
}
|
|
||||||
|
|
||||||
return request.getProvider().getEpisodeListLink(getSearchResult());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Collection<Episode> episodes) {
|
public void process(Collection<Episode> episodes) {
|
||||||
// set a proper title for the export handler before adding episodes
|
// set a proper title for the export handler before adding episodes
|
||||||
|
@ -256,35 +249,35 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
getComponent().getModel().addAll(episodes);
|
getComponent().getModel().addAll(episodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatusMessage(Collection<Episode> result) {
|
public String getStatusMessage(Collection<Episode> result) {
|
||||||
return (result.isEmpty()) ? "No episodes found" : String.format("%d episodes", result.size());
|
return (result.isEmpty()) ? "No episodes found" : String.format("%d episodes", result.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EpisodeListTab getComponent() {
|
public EpisodeListTab getComponent() {
|
||||||
return (EpisodeListTab) super.getComponent();
|
return (EpisodeListTab) super.getComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
if (request.getSeason() == ALL_SEASONS)
|
if (request.season == ALL_SEASONS)
|
||||||
return super.getTitle();
|
return super.getTitle();
|
||||||
|
|
||||||
// add additional information to default title
|
// add additional information to default title
|
||||||
return String.format("%s - Season %d", super.getTitle(), request.getSeason());
|
return String.format("%s - Season %d", super.getTitle(), request.season);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Icon getIcon() {
|
public Icon getIcon() {
|
||||||
return request.getProvider().getIcon();
|
return request.provider.getIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureSelectDialog(SelectDialog<SearchResult> selectDialog) {
|
protected void configureSelectDialog(SelectDialog<SearchResult> selectDialog) {
|
||||||
super.configureSelectDialog(selectDialog);
|
super.configureSelectDialog(selectDialog);
|
||||||
|
@ -293,7 +286,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static class EpisodeListTab extends FileBotList<Episode> {
|
protected static class EpisodeListTab extends FileBotList<Episode> {
|
||||||
|
|
||||||
public EpisodeListTab() {
|
public EpisodeListTab() {
|
||||||
|
@ -311,14 +304,14 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static class EpisodeListExportHandler extends FileBotListExportHandler implements ClipboardHandler {
|
protected static class EpisodeListExportHandler extends FileBotListExportHandler implements ClipboardHandler {
|
||||||
|
|
||||||
public EpisodeListExportHandler(FileBotList<Episode> list) {
|
public EpisodeListExportHandler(FileBotList<Episode> list) {
|
||||||
super(list);
|
super(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Transferable createTransferable(JComponent c) {
|
public Transferable createTransferable(JComponent c) {
|
||||||
Transferable episodeArray = new ArrayTransferable<Episode>(list.getModel().toArray(new Episode[0]));
|
Transferable episodeArray = new ArrayTransferable<Episode>(list.getModel().toArray(new Episode[0]));
|
||||||
|
@ -327,7 +320,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
||||||
return new CompositeTranserable(episodeArray, textFile);
|
return new CompositeTranserable(episodeArray, textFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exportToClipboard(JComponent c, Clipboard clipboard, int action) throws IllegalStateException {
|
public void exportToClipboard(JComponent c, Clipboard clipboard, int action) throws IllegalStateException {
|
||||||
Object[] selection = list.getListComponent().getSelectedValues();
|
Object[] selection = list.getListComponent().getSelectedValues();
|
||||||
|
|
|
@ -8,9 +8,10 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import net.sourceforge.filebot.similarity.Match;
|
import net.sourceforge.filebot.similarity.Match;
|
||||||
|
import net.sourceforge.filebot.web.SortOrder;
|
||||||
|
|
||||||
|
|
||||||
interface AutoCompleteMatcher {
|
interface AutoCompleteMatcher {
|
||||||
|
|
||||||
List<Match<File, ?>> match(List<File> files, Locale locale, boolean autodetection, Component parent) throws Exception;
|
List<Match<File, ?>> match(List<File> files, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import net.sourceforge.filebot.ui.SelectDialog;
|
||||||
import net.sourceforge.filebot.web.Episode;
|
import net.sourceforge.filebot.web.Episode;
|
||||||
import net.sourceforge.filebot.web.EpisodeListProvider;
|
import net.sourceforge.filebot.web.EpisodeListProvider;
|
||||||
import net.sourceforge.filebot.web.SearchResult;
|
import net.sourceforge.filebot.web.SearchResult;
|
||||||
|
import net.sourceforge.filebot.web.SortOrder;
|
||||||
|
|
||||||
|
|
||||||
class EpisodeListMatcher implements AutoCompleteMatcher {
|
class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
|
@ -119,7 +120,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Set<Episode> fetchEpisodeSet(Collection<String> seriesNames, final Locale locale, final Component parent) throws Exception {
|
protected Set<Episode> fetchEpisodeSet(Collection<String> seriesNames, final SortOrder sortOrder, final Locale locale, final Component parent) throws Exception {
|
||||||
List<Callable<List<Episode>>> tasks = new ArrayList<Callable<List<Episode>>>();
|
List<Callable<List<Episode>>> tasks = new ArrayList<Callable<List<Episode>>>();
|
||||||
|
|
||||||
// detect series names and create episode list fetch tasks
|
// detect series names and create episode list fetch tasks
|
||||||
|
@ -135,7 +136,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
SearchResult selectedSearchResult = selectSearchResult(query, results, parent);
|
SearchResult selectedSearchResult = selectSearchResult(query, results, parent);
|
||||||
|
|
||||||
if (selectedSearchResult != null) {
|
if (selectedSearchResult != null) {
|
||||||
List<Episode> episodes = provider.getEpisodeList(selectedSearchResult, locale);
|
List<Episode> episodes = provider.getEpisodeList(selectedSearchResult, sortOrder, locale);
|
||||||
Analytics.trackEvent(provider.getName(), "FetchEpisodeList", selectedSearchResult.getName());
|
Analytics.trackEvent(provider.getName(), "FetchEpisodeList", selectedSearchResult.getName());
|
||||||
|
|
||||||
return episodes;
|
return episodes;
|
||||||
|
@ -168,9 +169,9 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Match<File, ?>> match(final List<File> files, final Locale locale, final boolean autodetection, final Component parent) throws Exception {
|
public List<Match<File, ?>> match(final List<File> files, final SortOrder sortOrder, final Locale locale, final boolean autodetection, final Component parent) throws Exception {
|
||||||
// focus on movie and subtitle files
|
// focus on movie and subtitle files
|
||||||
final List<File> mediaFiles = filter(files, VIDEO_FILES, SUBTITLE_FILES);;
|
final List<File> mediaFiles = filter(files, VIDEO_FILES, SUBTITLE_FILES);
|
||||||
|
|
||||||
// assume that many shows will be matched, do it folder by folder
|
// assume that many shows will be matched, do it folder by folder
|
||||||
List<Callable<List<Match<File, ?>>>> taskPerFolder = new ArrayList<Callable<List<Match<File, ?>>>>();
|
List<Callable<List<Match<File, ?>>>> taskPerFolder = new ArrayList<Callable<List<Match<File, ?>>>>();
|
||||||
|
@ -192,7 +193,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Match<File, ?>> call() throws Exception {
|
public List<Match<File, ?>> call() throws Exception {
|
||||||
return matchEpisodeSet(batchSet, locale, autodetection, parent);
|
return matchEpisodeSet(batchSet, sortOrder, locale, autodetection, parent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -217,7 +218,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Match<File, ?>> matchEpisodeSet(final List<File> files, Locale locale, boolean autodetection, Component parent) throws Exception {
|
public List<Match<File, ?>> matchEpisodeSet(final List<File> files, SortOrder sortOrder, Locale locale, boolean autodetection, Component parent) throws Exception {
|
||||||
Set<Episode> episodes = emptySet();
|
Set<Episode> episodes = emptySet();
|
||||||
|
|
||||||
// detect series name and fetch episode list
|
// detect series name and fetch episode list
|
||||||
|
@ -226,7 +227,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
if (names.size() > 0) {
|
if (names.size() > 0) {
|
||||||
// only allow one fetch session at a time so later requests can make use of cached results
|
// only allow one fetch session at a time so later requests can make use of cached results
|
||||||
synchronized (providerLock) {
|
synchronized (providerLock) {
|
||||||
episodes = fetchEpisodeSet(names, locale, parent);
|
episodes = fetchEpisodeSet(names, sortOrder, locale, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +251,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||||
if (input.size() > 0) {
|
if (input.size() > 0) {
|
||||||
// only allow one fetch session at a time so later requests can make use of cached results
|
// only allow one fetch session at a time so later requests can make use of cached results
|
||||||
synchronized (providerLock) {
|
synchronized (providerLock) {
|
||||||
episodes = fetchEpisodeSet(input, locale, parent);
|
episodes = fetchEpisodeSet(input, sortOrder, locale, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import net.sourceforge.filebot.ui.SelectDialog;
|
||||||
import net.sourceforge.filebot.web.Movie;
|
import net.sourceforge.filebot.web.Movie;
|
||||||
import net.sourceforge.filebot.web.MovieIdentificationService;
|
import net.sourceforge.filebot.web.MovieIdentificationService;
|
||||||
import net.sourceforge.filebot.web.MoviePart;
|
import net.sourceforge.filebot.web.MoviePart;
|
||||||
|
import net.sourceforge.filebot.web.SortOrder;
|
||||||
|
|
||||||
|
|
||||||
class MovieHashMatcher implements AutoCompleteMatcher {
|
class MovieHashMatcher implements AutoCompleteMatcher {
|
||||||
|
@ -56,7 +57,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Match<File, ?>> match(final List<File> files, final Locale locale, final boolean autodetect, final Component parent) throws Exception {
|
public List<Match<File, ?>> match(final List<File> files, final SortOrder sortOrder, final Locale locale, final boolean autodetect, final Component parent) throws Exception {
|
||||||
// handle movie files
|
// handle movie files
|
||||||
List<File> movieFiles = filter(files, VIDEO_FILES);
|
List<File> movieFiles = filter(files, VIDEO_FILES);
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,17 @@ import javax.swing.Action;
|
||||||
import javax.swing.DefaultListCellRenderer;
|
import javax.swing.DefaultListCellRenderer;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
import ca.odell.glazedlists.ListSelection;
|
import ca.odell.glazedlists.ListSelection;
|
||||||
import ca.odell.glazedlists.swing.EventSelectionModel;
|
import ca.odell.glazedlists.swing.EventSelectionModel;
|
||||||
|
@ -49,6 +53,7 @@ import net.sourceforge.filebot.web.EpisodeListProvider;
|
||||||
import net.sourceforge.filebot.web.Movie;
|
import net.sourceforge.filebot.web.Movie;
|
||||||
import net.sourceforge.filebot.web.MovieFormat;
|
import net.sourceforge.filebot.web.MovieFormat;
|
||||||
import net.sourceforge.filebot.web.MovieIdentificationService;
|
import net.sourceforge.filebot.web.MovieIdentificationService;
|
||||||
|
import net.sourceforge.filebot.web.SortOrder;
|
||||||
import net.sourceforge.tuned.ExceptionUtilities;
|
import net.sourceforge.tuned.ExceptionUtilities;
|
||||||
import net.sourceforge.tuned.PreferencesMap.PreferencesEntry;
|
import net.sourceforge.tuned.PreferencesMap.PreferencesEntry;
|
||||||
import net.sourceforge.tuned.ui.ActionPopup;
|
import net.sourceforge.tuned.ui.ActionPopup;
|
||||||
|
@ -71,8 +76,9 @@ public class RenamePanel extends JComponent {
|
||||||
private static final PreferencesEntry<String> persistentEpisodeFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.episode");
|
private static final PreferencesEntry<String> persistentEpisodeFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.episode");
|
||||||
private static final PreferencesEntry<String> persistentMovieFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.movie");
|
private static final PreferencesEntry<String> persistentMovieFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.movie");
|
||||||
private static final PreferencesEntry<String> persistentPreferredLanguage = Settings.forPackage(RenamePanel.class).entry("rename.language").defaultValue("en");
|
private static final PreferencesEntry<String> persistentPreferredLanguage = Settings.forPackage(RenamePanel.class).entry("rename.language").defaultValue("en");
|
||||||
|
private static final PreferencesEntry<String> persistentPreferredEpisodeOrder = Settings.forPackage(RenamePanel.class).entry("rename.episode.order").defaultValue("Airdate");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public RenamePanel() {
|
public RenamePanel() {
|
||||||
namesList.setTitle("New Names");
|
namesList.setTitle("New Names");
|
||||||
namesList.setTransferablePolicy(new NamesListTransferablePolicy(renameModel.values()));
|
namesList.setTransferablePolicy(new NamesListTransferablePolicy(renameModel.values()));
|
||||||
|
@ -152,7 +158,7 @@ public class RenamePanel extends JComponent {
|
||||||
add(new LoadingOverlayPane(namesList, namesList, "32px", "30px"), "grow, sizegroupx list");
|
add(new LoadingOverlayPane(namesList, namesList, "32px", "30px"), "grow, sizegroupx list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected ActionPopup createFetchPopup() {
|
protected ActionPopup createFetchPopup() {
|
||||||
final ActionPopup actionPopup = new ActionPopup("Fetch Episode List", ResourceManager.getIcon("action.fetch"));
|
final ActionPopup actionPopup = new ActionPopup("Fetch Episode List", ResourceManager.getIcon("action.fetch"));
|
||||||
|
|
||||||
|
@ -203,8 +209,9 @@ public class RenamePanel extends JComponent {
|
||||||
languages.addAll(Language.preferredLanguages()); // add preferred languages first
|
languages.addAll(Language.preferredLanguages()); // add preferred languages first
|
||||||
languages.addAll(Language.availableLanguages()); // then others
|
languages.addAll(Language.availableLanguages()); // then others
|
||||||
|
|
||||||
JList message = new JList(languages.toArray());
|
JComboBox orderCombo = new JComboBox(SortOrder.values());
|
||||||
message.setCellRenderer(new DefaultListCellRenderer() {
|
JList languageList = new JList(languages.toArray());
|
||||||
|
languageList.setCellRenderer(new DefaultListCellRenderer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
@ -214,19 +221,33 @@ public class RenamePanel extends JComponent {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// pre-select current language preferences
|
// pre-select current preferences
|
||||||
|
try {
|
||||||
|
orderCombo.setSelectedItem(SortOrder.forName(persistentPreferredEpisodeOrder.getValue()));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
for (Language language : languages) {
|
for (Language language : languages) {
|
||||||
if (language.getCode().equals(persistentPreferredLanguage.getValue())) {
|
if (language.getCode().equals(persistentPreferredLanguage.getValue())) {
|
||||||
message.setSelectedValue(language, true);
|
languageList.setSelectedValue(language, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JOptionPane pane = new JOptionPane(new JScrollPane(message), PLAIN_MESSAGE, OK_CANCEL_OPTION);
|
JScrollPane spLanguageList = new JScrollPane(languageList);
|
||||||
pane.createDialog(getWindowAncestor(RenamePanel.this), "Language Preference").setVisible(true);
|
spLanguageList.setBorder(new CompoundBorder(new TitledBorder("Preferred Language"), spLanguageList.getBorder()));
|
||||||
|
JScrollPane spOrderCombo = new JScrollPane(orderCombo, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
spOrderCombo.setBorder(new CompoundBorder(new TitledBorder("Preferred Episode Order"), spOrderCombo.getBorder()));
|
||||||
|
|
||||||
|
JPanel message = new JPanel(new MigLayout("fill, flowy, insets 0"));
|
||||||
|
message.add(spLanguageList, "grow");
|
||||||
|
message.add(spOrderCombo, "grow, hmin 24px");
|
||||||
|
JOptionPane pane = new JOptionPane(message, PLAIN_MESSAGE, OK_CANCEL_OPTION);
|
||||||
|
pane.createDialog(getWindowAncestor(RenamePanel.this), "Preferences").setVisible(true);
|
||||||
|
|
||||||
if (pane.getValue() != null && pane.getValue().equals(OK_OPTION)) {
|
if (pane.getValue() != null && pane.getValue().equals(OK_OPTION)) {
|
||||||
persistentPreferredLanguage.setValue(((Language) message.getSelectedValue()).getCode());
|
persistentPreferredLanguage.setValue(((Language) languageList.getSelectedValue()).getCode());
|
||||||
|
persistentPreferredEpisodeOrder.setValue(((SortOrder) orderCombo.getSelectedItem()).name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -234,7 +255,7 @@ public class RenamePanel extends JComponent {
|
||||||
return actionPopup;
|
return actionPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected ActionPopup createSettingsPopup() {
|
protected ActionPopup createSettingsPopup() {
|
||||||
ActionPopup actionPopup = new ActionPopup("Rename Options", ResourceManager.getIcon("action.rename.small"));
|
ActionPopup actionPopup = new ActionPopup("Rename Options", ResourceManager.getIcon("action.rename.small"));
|
||||||
|
|
||||||
|
@ -269,7 +290,7 @@ public class RenamePanel extends JComponent {
|
||||||
return actionPopup;
|
return actionPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected final Action showPopupAction = new AbstractAction("Show Popup") {
|
protected final Action showPopupAction = new AbstractAction("Show Popup") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -284,18 +305,18 @@ public class RenamePanel extends JComponent {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected class PreserveExtensionAction extends AbstractAction {
|
protected class PreserveExtensionAction extends AbstractAction {
|
||||||
|
|
||||||
private final boolean activate;
|
private final boolean activate;
|
||||||
|
|
||||||
|
|
||||||
private PreserveExtensionAction(boolean activate, String name, Icon icon) {
|
private PreserveExtensionAction(boolean activate, String name, Icon icon) {
|
||||||
super(name, icon);
|
super(name, icon);
|
||||||
this.activate = activate;
|
this.activate = activate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
renameModel.setPreserveExtension(activate);
|
renameModel.setPreserveExtension(activate);
|
||||||
|
@ -311,12 +332,12 @@ public class RenamePanel extends JComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected class AutoCompleteAction extends AbstractAction {
|
protected class AutoCompleteAction extends AbstractAction {
|
||||||
|
|
||||||
private final AutoCompleteMatcher matcher;
|
private final AutoCompleteMatcher matcher;
|
||||||
|
|
||||||
|
|
||||||
public AutoCompleteAction(String name, Icon icon, AutoCompleteMatcher matcher) {
|
public AutoCompleteAction(String name, Icon icon, AutoCompleteMatcher matcher) {
|
||||||
super(name, icon);
|
super(name, icon);
|
||||||
|
|
||||||
|
@ -333,7 +354,7 @@ public class RenamePanel extends JComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(final ActionEvent evt) {
|
public void actionPerformed(final ActionEvent evt) {
|
||||||
if (renameModel.files().isEmpty()) {
|
if (renameModel.files().isEmpty()) {
|
||||||
|
@ -349,13 +370,14 @@ public class RenamePanel extends JComponent {
|
||||||
SwingWorker<List<Match<File, ?>>, Void> worker = new SwingWorker<List<Match<File, ?>>, Void>() {
|
SwingWorker<List<Match<File, ?>>, Void> worker = new SwingWorker<List<Match<File, ?>>, Void>() {
|
||||||
|
|
||||||
private final List<File> remainingFiles = new LinkedList<File>(renameModel.files());
|
private final List<File> remainingFiles = new LinkedList<File>(renameModel.files());
|
||||||
|
private final SortOrder order = SortOrder.forName(persistentPreferredEpisodeOrder.getValue());
|
||||||
private final Locale locale = new Locale(persistentPreferredLanguage.getValue());
|
private final Locale locale = new Locale(persistentPreferredLanguage.getValue());
|
||||||
private final boolean autodetection = !isShiftDown(evt); // skip name auto-detection if SHIFT is pressed
|
private final boolean autodetection = !isShiftDown(evt); // skip name auto-detection if SHIFT is pressed
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Match<File, ?>> doInBackground() throws Exception {
|
protected List<Match<File, ?>> doInBackground() throws Exception {
|
||||||
List<Match<File, ?>> matches = matcher.match(remainingFiles, locale, autodetection, getWindow(RenamePanel.this));
|
List<Match<File, ?>> matches = matcher.match(remainingFiles, order, locale, autodetection, getWindow(RenamePanel.this));
|
||||||
|
|
||||||
// remove matched files
|
// remove matched files
|
||||||
for (Match<File, ?> match : matches) {
|
for (Match<File, ?> match : matches) {
|
||||||
|
@ -365,7 +387,7 @@ public class RenamePanel extends JComponent {
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -32,7 +30,7 @@ public abstract class AbstractEpisodeListProvider implements EpisodeListProvider
|
||||||
protected abstract List<SearchResult> fetchSearchResult(String query, Locale locale) throws Exception;
|
protected abstract List<SearchResult> fetchSearchResult(String query, Locale locale) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
protected abstract List<Episode> fetchEpisodeList(SearchResult searchResult, Locale locale) throws Exception;
|
protected abstract List<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
public List<SearchResult> search(String query) throws Exception {
|
public List<SearchResult> search(String query) throws Exception {
|
||||||
|
@ -56,40 +54,22 @@ public abstract class AbstractEpisodeListProvider implements EpisodeListProvider
|
||||||
|
|
||||||
|
|
||||||
public List<Episode> getEpisodeList(SearchResult searchResult) throws Exception {
|
public List<Episode> getEpisodeList(SearchResult searchResult) throws Exception {
|
||||||
return getEpisodeList(searchResult, getDefaultLocale());
|
return getEpisodeList(searchResult, SortOrder.Airdate, getDefaultLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Episode> getEpisodeList(SearchResult searchResult, Locale locale) throws Exception {
|
public List<Episode> getEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws Exception {
|
||||||
ResultCache cache = getCache();
|
ResultCache cache = getCache();
|
||||||
List<Episode> episodes = (cache != null) ? cache.getEpisodeList(searchResult, locale) : null;
|
List<Episode> episodes = (cache != null) ? cache.getEpisodeList(searchResult, sortOrder, locale) : null;
|
||||||
if (episodes != null) {
|
if (episodes != null) {
|
||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform actual search
|
// perform actual search
|
||||||
episodes = fetchEpisodeList(searchResult, locale);
|
episodes = fetchEpisodeList(searchResult, sortOrder, locale);
|
||||||
|
|
||||||
// cache results and return
|
// cache results and return
|
||||||
return (cache != null) ? cache.putEpisodeList(searchResult, locale, episodes) : episodes;
|
return (cache != null) ? cache.putEpisodeList(searchResult, sortOrder, locale, episodes) : episodes;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<Episode> getEpisodeList(SearchResult searchResult, int season) throws Exception {
|
|
||||||
return getEpisodeList(searchResult, season, getDefaultLocale());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Episode> getEpisodeList(SearchResult searchResult, int season, Locale locale) throws Exception {
|
|
||||||
List<Episode> all = getEpisodeList(searchResult, locale);
|
|
||||||
List<Episode> eps = filterBySeason(all, season);
|
|
||||||
|
|
||||||
if (eps.isEmpty()) {
|
|
||||||
throw new SeasonOutOfBoundsException(searchResult.getName(), season, getLastSeason(all));
|
|
||||||
}
|
|
||||||
|
|
||||||
return eps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,9 +125,9 @@ public abstract class AbstractEpisodeListProvider implements EpisodeListProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Episode> putEpisodeList(SearchResult key, Locale locale, List<Episode> episodes) {
|
public List<Episode> putEpisodeList(SearchResult key, SortOrder sortOrder, Locale locale, List<Episode> episodes) {
|
||||||
try {
|
try {
|
||||||
cache.put(new Element(new Key(id, key, locale), episodes.toArray(new Episode[0])));
|
cache.put(new Element(new Key(id, key, sortOrder, locale), episodes.toArray(new Episode[0])));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger(AbstractEpisodeListProvider.class.getName()).log(Level.WARNING, e.getMessage(), e);
|
Logger.getLogger(AbstractEpisodeListProvider.class.getName()).log(Level.WARNING, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -156,9 +136,9 @@ public abstract class AbstractEpisodeListProvider implements EpisodeListProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Episode> getEpisodeList(SearchResult key, Locale locale) {
|
public List<Episode> getEpisodeList(SearchResult key, SortOrder sortOrder, Locale locale) {
|
||||||
try {
|
try {
|
||||||
Element element = cache.get(new Key(id, key, locale));
|
Element element = cache.get(new Key(id, key, sortOrder, locale));
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
return Arrays.asList((Episode[]) element.getValue());
|
return Arrays.asList((Episode[]) element.getValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Episode> fetchEpisodeList(SearchResult searchResult, Locale language) throws Exception {
|
public List<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale language) throws Exception {
|
||||||
AnidbSearchResult anime = (AnidbSearchResult) searchResult;
|
AnidbSearchResult anime = (AnidbSearchResult) searchResult;
|
||||||
|
|
||||||
// e.g. http://api.anidb.net:9001/httpapi?request=anime&client=filebot&clientver=1&protover=1&aid=4521
|
// e.g. http://api.anidb.net:9001/httpapi?request=anime&client=filebot&clientver=1&protover=1&aid=4521
|
||||||
|
@ -145,28 +145,14 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getEpisodeListLink(SearchResult searchResult) {
|
public URI getEpisodeListLink(SearchResult searchResult) {
|
||||||
int aid = ((AnidbSearchResult) searchResult).getAnimeId();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new URI("http", host, "/a" + aid, null);
|
return new URI("http", host, "/a" + ((AnidbSearchResult) searchResult).getAnimeId(), null);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Episode> getEpisodeList(SearchResult searchResult, int season, Locale locale) throws Exception {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public URI getEpisodeListLink(SearchResult searchResult, int season) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public synchronized List<AnidbSearchResult> getAnimeTitles() throws Exception {
|
public synchronized List<AnidbSearchResult> getAnimeTitles() throws Exception {
|
||||||
URL url = new URL("http", host, "/api/animetitles.dat.gz");
|
URL url = new URL("http", host, "/api/animetitles.dat.gz");
|
||||||
ResultCache cache = getCache();
|
ResultCache cache = getCache();
|
||||||
|
|
|
@ -13,28 +13,22 @@ public interface EpisodeListProvider {
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
|
||||||
public Icon getIcon();
|
public Icon getIcon();
|
||||||
|
|
||||||
|
|
||||||
public boolean hasSingleSeasonSupport();
|
public boolean hasSingleSeasonSupport();
|
||||||
|
|
||||||
|
|
||||||
public boolean hasLocaleSupport();
|
public boolean hasLocaleSupport();
|
||||||
|
|
||||||
|
|
||||||
public List<SearchResult> search(String query, Locale locale) throws Exception;
|
public List<SearchResult> search(String query, Locale locale) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
public List<Episode> getEpisodeList(SearchResult searchResult, Locale locale) throws Exception;
|
|
||||||
|
|
||||||
|
public List<Episode> getEpisodeList(SearchResult searchResult, SortOrder order, Locale locale) throws Exception;
|
||||||
public List<Episode> getEpisodeList(SearchResult searchResult, int season, Locale locale) throws Exception;
|
|
||||||
|
|
||||||
|
|
||||||
public URI getEpisodeListLink(SearchResult searchResult);
|
public URI getEpisodeListLink(SearchResult searchResult);
|
||||||
|
|
||||||
|
|
||||||
public URI getEpisodeListLink(SearchResult searchResult, int season);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@ public final class EpisodeUtilities {
|
||||||
return name.replaceAll("[(]([^)]*)[)]", "").trim();
|
return name.replaceAll("[(]([^)]*)[)]", "").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<Episode> filterBySeason(Iterable<Episode> episodes, int season) {
|
public static List<Episode> filterBySeason(Iterable<Episode> episodes, int season) {
|
||||||
List<Episode> results = new ArrayList<Episode>(25);
|
List<Episode> results = new ArrayList<Episode>(25);
|
||||||
|
|
||||||
// filter given season from all seasons
|
// filter given season from all seasons
|
||||||
for (Episode episode : episodes) {
|
for (Episode episode : episodes) {
|
||||||
if (season == episode.getSeason()) {
|
if (episode.getSeason() != null && season == episode.getSeason()) {
|
||||||
results.add(episode);
|
results.add(episode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public final class EpisodeUtilities {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getLastSeason(Iterable<Episode> episodes) {
|
public static int getLastSeason(Iterable<Episode> episodes) {
|
||||||
int lastSeason = 0;
|
int lastSeason = 0;
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ public final class EpisodeUtilities {
|
||||||
return lastSeason;
|
return lastSeason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sortEpisodes(List<Episode> episodes) {
|
public static void sortEpisodes(List<Episode> episodes) {
|
||||||
Collections.sort(episodes, episodeComparator());
|
Collections.sort(episodes, episodeComparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Comparator<Episode> episodeComparator() {
|
public static Comparator<Episode> episodeComparator() {
|
||||||
return new Comparator<Episode>() {
|
return new Comparator<Episode>() {
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public final class EpisodeUtilities {
|
||||||
return compareValue(a.getTitle(), b.getTitle());
|
return compareValue(a.getTitle(), b.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private <T> int compareValue(Comparable<T> o1, T o2) {
|
private <T> int compareValue(Comparable<T> o1, T o2) {
|
||||||
if (o1 == null && o2 == null)
|
if (o1 == null && o2 == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -83,7 +83,7 @@ public final class EpisodeUtilities {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private EpisodeUtilities() {
|
private EpisodeUtilities() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -78,7 +76,6 @@ public class IMDbClient implements MovieIdentificationService {
|
||||||
results.add(new Movie(name, Integer.parseInt(year), getImdbId(href)));
|
results.add(new Movie(name, Integer.parseInt(year), getImdbId(href)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore illegal movies (TV Shows, Videos, Video Games, etc)
|
// ignore illegal movies (TV Shows, Videos, Video Games, etc)
|
||||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getClass().getName() + ": " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class SerienjunkiesClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Episode> fetchEpisodeList(SearchResult searchResult, Locale locale) throws IOException {
|
public List<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws IOException {
|
||||||
SerienjunkiesSearchResult series = (SerienjunkiesSearchResult) searchResult;
|
SerienjunkiesSearchResult series = (SerienjunkiesSearchResult) searchResult;
|
||||||
|
|
||||||
// fetch episode data
|
// fetch episode data
|
||||||
|
@ -162,18 +162,7 @@ public class SerienjunkiesClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getEpisodeListLink(SearchResult searchResult) {
|
public URI getEpisodeListLink(SearchResult searchResult) {
|
||||||
return getEpisodeListLink(searchResult, "alle-serien-staffeln");
|
return URI.create(String.format("http://www.serienjunkies.de/%s/alle-serien-staffeln.html", ((SerienjunkiesSearchResult) searchResult).getLink()));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public URI getEpisodeListLink(SearchResult searchResult, int season) {
|
|
||||||
return getEpisodeListLink(searchResult, "season" + season);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public URI getEpisodeListLink(SearchResult searchResult, String page) {
|
|
||||||
return URI.create(String.format("http://www.serienjunkies.de/%s/%s.html", ((SerienjunkiesSearchResult) searchResult).getLink(), page));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
|
public enum SortOrder {
|
||||||
|
Airdate,
|
||||||
|
DVD,
|
||||||
|
Absolute;
|
||||||
|
|
||||||
|
public static SortOrder forName(String name) {
|
||||||
|
for (SortOrder order : SortOrder.values()) {
|
||||||
|
if (order.name().equalsIgnoreCase(name)) {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Invalid SortOrder: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s Order", name());
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,25 +27,25 @@ public class TVRageClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
private final String host = "services.tvrage.com";
|
private final String host = "services.tvrage.com";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "TVRage";
|
return "TVRage";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Icon getIcon() {
|
public Icon getIcon() {
|
||||||
return ResourceManager.getIcon("search.tvrage");
|
return ResourceManager.getIcon("search.tvrage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultCache getCache() {
|
public ResultCache getCache() {
|
||||||
return new ResultCache(host, CacheManager.getInstance().getCache("web-datasource"));
|
return new ResultCache(host, CacheManager.getInstance().getCache("web-datasource"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SearchResult> fetchSearchResult(String query, Locale locale) throws IOException, SAXException {
|
public List<SearchResult> fetchSearchResult(String query, Locale locale) throws IOException, SAXException {
|
||||||
URL searchUrl = new URL("http", host, "/feeds/full_search.php?show=" + encode(query));
|
URL searchUrl = new URL("http", host, "/feeds/full_search.php?show=" + encode(query));
|
||||||
|
@ -65,9 +65,9 @@ public class TVRageClient extends AbstractEpisodeListProvider {
|
||||||
return searchResults;
|
return searchResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Episode> fetchEpisodeList(SearchResult searchResult, Locale locale) throws IOException, SAXException {
|
public List<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws IOException, SAXException {
|
||||||
TVRageSearchResult series = (TVRageSearchResult) searchResult;
|
TVRageSearchResult series = (TVRageSearchResult) searchResult;
|
||||||
|
|
||||||
URL episodeListUrl = new URL("http", host, "/feeds/full_show_info.php?sid=" + series.getSeriesId());
|
URL episodeListUrl = new URL("http", host, "/feeds/full_show_info.php?sid=" + series.getSeriesId());
|
||||||
|
@ -95,6 +95,11 @@ public class TVRageClient extends AbstractEpisodeListProvider {
|
||||||
specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, title, null, specialNumber, airdate));
|
specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, title, null, specialNumber, airdate));
|
||||||
} else {
|
} else {
|
||||||
// handle as normal episode
|
// handle as normal episode
|
||||||
|
if (sortOrder == SortOrder.Absolute) {
|
||||||
|
episodeNumber = getIntegerContent("epnum", node);
|
||||||
|
seasonNumber = null;
|
||||||
|
}
|
||||||
|
|
||||||
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, title, null, null, airdate));
|
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, title, null, null, airdate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,60 +110,47 @@ public class TVRageClient extends AbstractEpisodeListProvider {
|
||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getEpisodeListLink(SearchResult searchResult) {
|
public URI getEpisodeListLink(SearchResult searchResult) {
|
||||||
return getEpisodeListLink(searchResult, "all");
|
return URI.create(((TVRageSearchResult) searchResult).getLink() + "/episode_list/all");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public URI getEpisodeListLink(SearchResult searchResult, int season) {
|
|
||||||
return getEpisodeListLink(searchResult, String.valueOf(season));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private URI getEpisodeListLink(SearchResult searchResult, String seasonString) {
|
|
||||||
String base = ((TVRageSearchResult) searchResult).getLink();
|
|
||||||
|
|
||||||
return URI.create(base + "/episode_list/" + seasonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class TVRageSearchResult extends SearchResult {
|
public static class TVRageSearchResult extends SearchResult {
|
||||||
|
|
||||||
protected int showId;
|
protected int showId;
|
||||||
protected String link;
|
protected String link;
|
||||||
|
|
||||||
|
|
||||||
protected TVRageSearchResult() {
|
protected TVRageSearchResult() {
|
||||||
// used by serializer
|
// used by serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TVRageSearchResult(String name, int showId, String link) {
|
public TVRageSearchResult(String name, int showId, String link) {
|
||||||
super(name);
|
super(name);
|
||||||
this.showId = showId;
|
this.showId = showId;
|
||||||
this.link = link;
|
this.link = link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getSeriesId() {
|
public int getSeriesId() {
|
||||||
return showId;
|
return showId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return showId;
|
return showId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object instanceof TVRageSearchResult) {
|
if (object instanceof TVRageSearchResult) {
|
||||||
|
|
|
@ -109,9 +109,8 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Episode> fetchEpisodeList(SearchResult searchResult, Locale language) throws Exception {
|
public List<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale language) throws Exception {
|
||||||
TheTVDBSearchResult series = (TheTVDBSearchResult) searchResult;
|
TheTVDBSearchResult series = (TheTVDBSearchResult) searchResult;
|
||||||
|
|
||||||
Document seriesRecord = getSeriesRecord(series, language);
|
Document seriesRecord = getSeriesRecord(series, language);
|
||||||
|
|
||||||
// we could get the series name from the search result, but the language may not match the given parameter
|
// we could get the series name from the search result, but the language may not match the given parameter
|
||||||
|
@ -130,17 +129,9 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
Integer absoluteNumber = getIntegerContent("absolute_number", node);
|
Integer absoluteNumber = getIntegerContent("absolute_number", node);
|
||||||
Date airdate = Date.parse(getTextContent("FirstAired", node), "yyyy-MM-dd");
|
Date airdate = Date.parse(getTextContent("FirstAired", node), "yyyy-MM-dd");
|
||||||
|
|
||||||
// prefer DVD SxE numbers if available
|
// default numbering
|
||||||
Integer seasonNumber;
|
Integer episodeNumber = getIntegerContent("EpisodeNumber", node);
|
||||||
Integer episodeNumber;
|
Integer seasonNumber = getIntegerContent("SeasonNumber", node);
|
||||||
|
|
||||||
try {
|
|
||||||
seasonNumber = new Integer(dvdSeasonNumber);
|
|
||||||
episodeNumber = new Float(dvdEpisodeNumber).intValue();
|
|
||||||
} catch (Exception e) {
|
|
||||||
seasonNumber = getIntegerContent("SeasonNumber", node);
|
|
||||||
episodeNumber = getIntegerContent("EpisodeNumber", node);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seasonNumber == null || seasonNumber == 0) {
|
if (seasonNumber == null || seasonNumber == 0) {
|
||||||
// handle as special episode
|
// handle as special episode
|
||||||
|
@ -154,6 +145,20 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, episodeName, null, specialNumber, airdate));
|
specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, episodeName, null, specialNumber, airdate));
|
||||||
} else {
|
} else {
|
||||||
// handle as normal episode
|
// handle as normal episode
|
||||||
|
if (sortOrder == SortOrder.Absolute) {
|
||||||
|
if (absoluteNumber != null) {
|
||||||
|
episodeNumber = absoluteNumber;
|
||||||
|
seasonNumber = null;
|
||||||
|
}
|
||||||
|
} else if (sortOrder == SortOrder.DVD) {
|
||||||
|
try {
|
||||||
|
episodeNumber = new Float(dvdEpisodeNumber).intValue();
|
||||||
|
seasonNumber = new Integer(dvdSeasonNumber);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore, fallback to default numbering
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, episodeName, absoluteNumber, null, airdate));
|
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, episodeName, absoluteNumber, null, airdate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,28 +242,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getEpisodeListLink(SearchResult searchResult) {
|
public URI getEpisodeListLink(SearchResult searchResult) {
|
||||||
int seriesId = ((TheTVDBSearchResult) searchResult).getSeriesId();
|
return URI.create("http://" + host + "/?tab=seasonall&id=" + ((TheTVDBSearchResult) searchResult).getSeriesId());
|
||||||
|
|
||||||
return URI.create("http://" + host + "/?tab=seasonall&id=" + seriesId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public URI getEpisodeListLink(SearchResult searchResult, int season) {
|
|
||||||
int seriesId = ((TheTVDBSearchResult) searchResult).getSeriesId();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// get episode xml from first episode of given season
|
|
||||||
Document dom = getDocument(getResource(MirrorType.XML, "/api/" + apikey + "/series/" + seriesId + "/default/" + season + "/1/en.xml"));
|
|
||||||
int seasonId = Integer.valueOf(selectString("Data/Episode/seasonid", dom));
|
|
||||||
|
|
||||||
return new URI("http://" + host + "/?tab=season&seriesid=" + seriesId + "&seasonid=" + seasonId);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// log and ignore any IOException
|
|
||||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Failed to retrieve season id", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@ import java.io.File;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.sourceforge.filebot.media.ReleaseInfo;
|
|
||||||
|
|
||||||
|
|
||||||
public class ReleaseInfoTest {
|
public class ReleaseInfoTest {
|
||||||
|
|
||||||
|
@ -18,10 +16,10 @@ public class ReleaseInfoTest {
|
||||||
ReleaseInfo info = new ReleaseInfo();
|
ReleaseInfo info = new ReleaseInfo();
|
||||||
File f = new File("Jurassic.Park[1993]DvDrip-aXXo.avi");
|
File f = new File("Jurassic.Park[1993]DvDrip-aXXo.avi");
|
||||||
|
|
||||||
assertEquals("DvDrip", info.getVideoSource(f));
|
assertEquals("DVDRip", info.getVideoSource(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getReleaseGroup() throws Exception {
|
public void getReleaseGroup() throws Exception {
|
||||||
ReleaseInfo info = new ReleaseInfo();
|
ReleaseInfo info = new ReleaseInfo();
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class SeriesNameMatcherTest {
|
||||||
|
|
||||||
private static SeriesNameMatcher matcher = new SeriesNameMatcher();
|
private static SeriesNameMatcher matcher = new SeriesNameMatcher();
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whitelist() {
|
public void whitelist() {
|
||||||
// ignore recurring word sequences when matching episode patterns
|
// ignore recurring word sequences when matching episode patterns
|
||||||
|
@ -22,7 +22,7 @@ public class SeriesNameMatcherTest {
|
||||||
assertArrayEquals(new String[] { "Test 101" }, matcher.matchAll(names).toArray());
|
assertArrayEquals(new String[] { "Test 101" }, matcher.matchAll(names).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void threshold() {
|
public void threshold() {
|
||||||
// ignore recurring word sequences when matching episode patterns
|
// ignore recurring word sequences when matching episode patterns
|
||||||
|
@ -31,16 +31,16 @@ public class SeriesNameMatcherTest {
|
||||||
assertArrayEquals(new String[] { "Test" }, matcher.matchAll(names).toArray());
|
assertArrayEquals(new String[] { "Test" }, matcher.matchAll(names).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void matchBeforeSeasonEpisodePattern() {
|
public void matchBeforeSeasonEpisodePattern() {
|
||||||
assertEquals("The Test", matcher.matchByEpisodeIdentifier("The Test - 1x01"));
|
assertEquals("The Test", matcher.matchByEpisodeIdentifier("The Test - 1x01"));
|
||||||
|
|
||||||
// real world test
|
// real world test
|
||||||
assertEquals("Mushishi", matcher.matchByEpisodeIdentifier("[niizk]_Mushishi_-_01_-_The_Green_Gathering"));
|
assertEquals("Mushishi", matcher.matchByEpisodeIdentifier("[niizk]_Mushishi_-_1x01_-_The_Green_Gathering"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void normalize() {
|
public void normalize() {
|
||||||
// non-letter and non-digit characters
|
// non-letter and non-digit characters
|
||||||
|
@ -53,7 +53,7 @@ public class SeriesNameMatcherTest {
|
||||||
assertEquals("strawhat Luffy", matcher.normalize("(strawhat [Luffy (#Monkey)"));
|
assertEquals("strawhat Luffy", matcher.normalize("(strawhat [Luffy (#Monkey)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void firstCommonSequence() {
|
public void firstCommonSequence() {
|
||||||
String[] seq1 = "Common Name 1 Any Title".split("\\s");
|
String[] seq1 = "Common Name 1 Any Title".split("\\s");
|
||||||
|
@ -67,7 +67,7 @@ public class SeriesNameMatcherTest {
|
||||||
assertArrayEquals(null, matcher.firstCommonSequence(seq2, seq1, 1, String.CASE_INSENSITIVE_ORDER));
|
assertArrayEquals(null, matcher.firstCommonSequence(seq2, seq1, 1, String.CASE_INSENSITIVE_ORDER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void firstCharacterCaseBalance() {
|
public void firstCharacterCaseBalance() {
|
||||||
SeriesNameCollection n = new SeriesNameCollection();
|
SeriesNameCollection n = new SeriesNameCollection();
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class AnidbClientTest {
|
||||||
*/
|
*/
|
||||||
private static AnidbSearchResult princessTutuSearchResult;
|
private static AnidbSearchResult princessTutuSearchResult;
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
monsterSearchResult = new AnidbSearchResult(1539, "Monster", null);
|
monsterSearchResult = new AnidbSearchResult(1539, "Monster", null);
|
||||||
|
@ -40,10 +40,10 @@ public class AnidbClientTest {
|
||||||
princessTutuSearchResult = new AnidbSearchResult(516, "Princess Tutu", null);
|
princessTutuSearchResult = new AnidbSearchResult(516, "Princess Tutu", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AnidbClient anidb = new AnidbClient("filebot", 2);
|
private AnidbClient anidb = new AnidbClient("filebot", 2);
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void search() throws Exception {
|
public void search() throws Exception {
|
||||||
List<SearchResult> results = anidb.search("one piece");
|
List<SearchResult> results = anidb.search("one piece");
|
||||||
|
@ -53,7 +53,7 @@ public class AnidbClientTest {
|
||||||
assertEquals(69, result.getAnimeId());
|
assertEquals(69, result.getAnimeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchJapanese() throws Exception {
|
public void searchJapanese() throws Exception {
|
||||||
List<SearchResult> results = anidb.search("ワンピース", Locale.JAPANESE);
|
List<SearchResult> results = anidb.search("ワンピース", Locale.JAPANESE);
|
||||||
|
@ -63,7 +63,7 @@ public class AnidbClientTest {
|
||||||
assertEquals(69, result.getAnimeId());
|
assertEquals(69, result.getAnimeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchNoMatch() throws Exception {
|
public void searchNoMatch() throws Exception {
|
||||||
List<SearchResult> results = anidb.search("i will not find anything for this query string");
|
List<SearchResult> results = anidb.search("i will not find anything for this query string");
|
||||||
|
@ -71,7 +71,7 @@ public class AnidbClientTest {
|
||||||
assertTrue(results.isEmpty());
|
assertTrue(results.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchTitleAlias() throws Exception {
|
public void searchTitleAlias() throws Exception {
|
||||||
// Seikai no Senki (main title), Banner of the Stars (official English title)
|
// Seikai no Senki (main title), Banner of the Stars (official English title)
|
||||||
|
@ -82,7 +82,7 @@ public class AnidbClientTest {
|
||||||
assertEquals("Naruto", anidb.search("naruto").get(0).getName());
|
assertEquals("Naruto", anidb.search("naruto").get(0).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListAll() throws Exception {
|
public void getEpisodeListAll() throws Exception {
|
||||||
List<Episode> list = anidb.getEpisodeList(monsterSearchResult);
|
List<Episode> list = anidb.getEpisodeList(monsterSearchResult);
|
||||||
|
@ -100,7 +100,7 @@ public class AnidbClientTest {
|
||||||
assertEquals("2004-04-07", first.airdate().toString());
|
assertEquals("2004-04-07", first.airdate().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListAllShortLink() throws Exception {
|
public void getEpisodeListAllShortLink() throws Exception {
|
||||||
List<Episode> list = anidb.getEpisodeList(twelvekingdomsSearchResult);
|
List<Episode> list = anidb.getEpisodeList(twelvekingdomsSearchResult);
|
||||||
|
@ -118,16 +118,16 @@ public class AnidbClientTest {
|
||||||
assertEquals("2002-04-09", first.airdate().toString());
|
assertEquals("2002-04-09", first.airdate().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListEncoding() throws Exception {
|
public void getEpisodeListEncoding() throws Exception {
|
||||||
assertEquals("Raven Princess - An der schönen blauen Donau", anidb.getEpisodeList(princessTutuSearchResult).get(6).getTitle());
|
assertEquals("Raven Princess - An der schönen blauen Donau", anidb.getEpisodeList(princessTutuSearchResult).get(6).getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListI18N() throws Exception {
|
public void getEpisodeListI18N() throws Exception {
|
||||||
List<Episode> list = anidb.getEpisodeList(monsterSearchResult, Locale.JAPANESE);
|
List<Episode> list = anidb.getEpisodeList(monsterSearchResult, SortOrder.Airdate, Locale.JAPANESE);
|
||||||
|
|
||||||
Episode last = list.get(73);
|
Episode last = list.get(73);
|
||||||
assertEquals("モンスター", last.getSeriesName());
|
assertEquals("モンスター", last.getSeriesName());
|
||||||
|
@ -139,19 +139,19 @@ public class AnidbClientTest {
|
||||||
assertEquals("2005-09-28", last.airdate().toString());
|
assertEquals("2005-09-28", last.airdate().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListTrimRecap() throws Exception {
|
public void getEpisodeListTrimRecap() throws Exception {
|
||||||
assertEquals("Sea God of the East, Azure Sea of the West - Transition Chapter", anidb.getEpisodeList(twelvekingdomsSearchResult).get(44).getTitle());
|
assertEquals("Sea God of the East, Azure Sea of the West - Transition Chapter", anidb.getEpisodeList(twelvekingdomsSearchResult).get(44).getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListLink() throws Exception {
|
public void getEpisodeListLink() throws Exception {
|
||||||
assertEquals("http://anidb.net/a1539", anidb.getEpisodeListLink(monsterSearchResult).toURL().toString());
|
assertEquals("http://anidb.net/a1539", anidb.getEpisodeListLink(monsterSearchResult).toURL().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void clearCache() {
|
public static void clearCache() {
|
||||||
|
|
|
@ -18,7 +18,6 @@ public class IMDbClientTest {
|
||||||
public void searchMovie() throws Exception {
|
public void searchMovie() throws Exception {
|
||||||
List<Movie> results = imdb.searchMovie("Avatar", null);
|
List<Movie> results = imdb.searchMovie("Avatar", null);
|
||||||
|
|
||||||
assertEquals(26, results.size());
|
|
||||||
Movie movie = (Movie) results.get(0);
|
Movie movie = (Movie) results.get(0);
|
||||||
|
|
||||||
assertEquals("Avatar", movie.getName());
|
assertEquals("Avatar", movie.getName());
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class OpenSubtitlesXmlRpcTest {
|
||||||
Movie sample = (Movie) list.get(0);
|
Movie sample = (Movie) list.get(0);
|
||||||
|
|
||||||
// check sample entry
|
// check sample entry
|
||||||
assertEquals("\"Babylon 5\"", sample.getName());
|
assertEquals("Babylon 5", sample.getName());
|
||||||
assertEquals(1994, sample.getYear());
|
assertEquals(1994, sample.getYear());
|
||||||
assertEquals(105946, sample.getImdbId());
|
assertEquals(105946, sample.getImdbId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,14 @@ public class SublightSubtitleClientTest {
|
||||||
|
|
||||||
private static SublightSubtitleClient client = new SublightSubtitleClient(getApplicationName(), getApplicationProperty("sublight.apikey"));
|
private static SublightSubtitleClient client = new SublightSubtitleClient(getApplicationName(), getApplicationProperty("sublight.apikey"));
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void login() {
|
public static void login() {
|
||||||
// login manually
|
// login manually
|
||||||
client.login();
|
client.login();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void search() {
|
public void search() {
|
||||||
List<SearchResult> list = client.search("babylon 5");
|
List<SearchResult> list = client.search("babylon 5");
|
||||||
|
@ -43,21 +43,19 @@ public class SublightSubtitleClientTest {
|
||||||
assertEquals(8, list.size());
|
assertEquals(8, list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleListEnglish() {
|
public void getSubtitleListEnglish() {
|
||||||
List<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Heroes", 2006, 813715), "English");
|
List<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Heroes", 2006, 813715), "English");
|
||||||
|
|
||||||
SubtitleDescriptor sample = list.get(0);
|
SubtitleDescriptor sample = list.get(0);
|
||||||
|
|
||||||
assertTrue(sample.getName().startsWith("Heroes"));
|
|
||||||
assertEquals("English", sample.getLanguageName());
|
assertEquals("English", sample.getLanguageName());
|
||||||
|
|
||||||
// check size
|
// check size
|
||||||
assertTrue(list.size() > 45);
|
assertTrue(list.size() > 45);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleListAllLanguages() {
|
public void getSubtitleListAllLanguages() {
|
||||||
List<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), null);
|
List<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), null);
|
||||||
|
@ -71,7 +69,7 @@ public class SublightSubtitleClientTest {
|
||||||
assertTrue(list.size() > 15);
|
assertTrue(list.size() > 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleListVideoHash() throws Exception {
|
public void getSubtitleListVideoHash() throws Exception {
|
||||||
List<Subtitle> list = client.getSubtitleList("001c6e0000320458004ee6f6859e5b7844767d44336e5624edbb", null, null, "English");
|
List<Subtitle> list = client.getSubtitleList("001c6e0000320458004ee6f6859e5b7844767d44336e5624edbb", null, null, "English");
|
||||||
|
@ -82,7 +80,7 @@ public class SublightSubtitleClientTest {
|
||||||
assertEquals(true, sample.isIsLinked());
|
assertEquals(true, sample.isIsLinked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getZipArchive() throws Exception {
|
public void getZipArchive() throws Exception {
|
||||||
Subtitle subtitle = new Subtitle();
|
Subtitle subtitle = new Subtitle();
|
||||||
|
@ -103,7 +101,7 @@ public class SublightSubtitleClientTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void logout() {
|
public static void logout() {
|
||||||
// logout manually
|
// logout manually
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class SubsceneSubtitleClientTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
twinpeaksSearchResult = new SubsceneSearchResult("Twin Peaks", "Twin Peaks - First Season (1990)", new URL("http://subscene.com/twin-peaks--first-season/subtitles-32482.aspx"));
|
twinpeaksSearchResult = new SubsceneSearchResult("Twin Peaks", "Twin Peaks - First Season (1990)", new URL("http://subscene.com/Twin-Peaks-First-Season/subtitles-32482.aspx"));
|
||||||
lostSearchResult = new SubsceneSearchResult("Lost", "Lost - Fourth Season (2008)", new URL("http://subscene.com/Lost-Fourth-Season/subtitles-70963.aspx"));
|
lostSearchResult = new SubsceneSearchResult("Lost", "Lost - Fourth Season (2008)", new URL("http://subscene.com/Lost-Fourth-Season/subtitles-70963.aspx"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +64,11 @@ public class SubsceneSubtitleClientTest {
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleListSearchResult() throws Exception {
|
public void getSubtitleListSearchResult() throws Exception {
|
||||||
List<SubtitleDescriptor> subtitleList = subscene.getSubtitleList(twinpeaksSearchResult, "Italian");
|
List<SubtitleDescriptor> subtitleList = subscene.getSubtitleList(twinpeaksSearchResult, "Italian");
|
||||||
assertEquals(1, subtitleList.size());
|
assertEquals(10, subtitleList.size());
|
||||||
|
|
||||||
SubtitleDescriptor subtitle = subtitleList.get(0);
|
SubtitleDescriptor subtitle = subtitleList.get(0);
|
||||||
assertEquals("Twin Peaks - First Season", subtitle.getName());
|
assertEquals("Twin Peaks - First Season", subtitle.getName());
|
||||||
assertEquals("Italian", subtitle.getLanguageName());
|
assertEquals("Italian", subtitle.getLanguageName());
|
||||||
assertEquals("zip", subtitle.getType());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class TVRageClientTest {
|
||||||
*/
|
*/
|
||||||
private static TVRageSearchResult buffySearchResult = new TVRageSearchResult("Buffy the Vampire Slayer", 2930, "http://www.tvrage.com/Buffy_The_Vampire_Slayer");
|
private static TVRageSearchResult buffySearchResult = new TVRageSearchResult("Buffy the Vampire Slayer", 2930, "http://www.tvrage.com/Buffy_The_Vampire_Slayer");
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void search() throws Exception {
|
public void search() throws Exception {
|
||||||
List<SearchResult> results = tvrage.search("Buffy");
|
List<SearchResult> results = tvrage.search("Buffy");
|
||||||
|
@ -30,13 +30,13 @@ public class TVRageClientTest {
|
||||||
assertEquals(buffySearchResult.getLink(), result.getLink());
|
assertEquals(buffySearchResult.getLink(), result.getLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TVRageClient tvrage = new TVRageClient();
|
private TVRageClient tvrage = new TVRageClient();
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeList() throws Exception {
|
public void getEpisodeList() throws Exception {
|
||||||
List<Episode> list = tvrage.getEpisodeList(buffySearchResult, 7);
|
List<Episode> list = EpisodeUtilities.filterBySeason(tvrage.getEpisodeList(buffySearchResult), 7);
|
||||||
|
|
||||||
assertEquals(22, list.size());
|
assertEquals(22, list.size());
|
||||||
|
|
||||||
|
@ -51,36 +51,24 @@ public class TVRageClientTest {
|
||||||
assertEquals("2003-05-20", chosen.airdate().toString());
|
assertEquals("2003-05-20", chosen.airdate().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListAll() throws Exception {
|
public void getEpisodeListAll() throws Exception {
|
||||||
List<Episode> list = tvrage.getEpisodeList(buffySearchResult);
|
List<Episode> list = tvrage.getEpisodeList(buffySearchResult);
|
||||||
|
|
||||||
assertEquals(145, list.size());
|
assertEquals(144, list.size());
|
||||||
|
|
||||||
Episode first = list.get(0);
|
Episode first = list.get(0);
|
||||||
|
|
||||||
assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
|
assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
|
||||||
assertEquals("Unaired Pilot", first.getTitle());
|
assertEquals("Welcome to the Hellmouth (1)", first.getTitle());
|
||||||
assertEquals("0", first.getEpisode().toString());
|
assertEquals("1", first.getEpisode().toString());
|
||||||
assertEquals("0", first.getSeason().toString());
|
assertEquals("1", first.getSeason().toString());
|
||||||
assertEquals(null, first.getAbsolute());
|
assertEquals(null, first.getAbsolute());
|
||||||
assertEquals(null, first.airdate());
|
assertEquals("1997-03-10", first.airdate().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expected = SeasonOutOfBoundsException.class)
|
|
||||||
public void getEpisodeListIllegalSeason() throws Exception {
|
|
||||||
tvrage.getEpisodeList(buffySearchResult, 42);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getEpisodeListLink() throws Exception {
|
|
||||||
assertEquals(tvrage.getEpisodeListLink(buffySearchResult, 1).toString(), "http://www.tvrage.com/Buffy_The_Vampire_Slayer/episode_list/1");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListLinkAll() throws Exception {
|
public void getEpisodeListLinkAll() throws Exception {
|
||||||
assertEquals(tvrage.getEpisodeListLink(buffySearchResult).toString(), "http://www.tvrage.com/Buffy_The_Vampire_Slayer/episode_list/all");
|
assertEquals(tvrage.getEpisodeListLink(buffySearchResult).toString(), "http://www.tvrage.com/Buffy_The_Vampire_Slayer/episode_list/all");
|
||||||
|
|
|
@ -83,9 +83,7 @@ public class TheTVDBClientTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListSingleSeason() throws Exception {
|
public void getEpisodeListSingleSeason() throws Exception {
|
||||||
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Wonderfalls", 78845), 1);
|
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Wonderfalls", 78845));
|
||||||
|
|
||||||
assertEquals(14, list.size());
|
|
||||||
|
|
||||||
Episode first = list.get(0);
|
Episode first = list.get(0);
|
||||||
|
|
||||||
|
@ -101,9 +99,7 @@ public class TheTVDBClientTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListNumbering() throws Exception {
|
public void getEpisodeListNumbering() throws Exception {
|
||||||
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Firefly", 78874), 1);
|
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Firefly", 78874), SortOrder.DVD, Locale.ENGLISH);
|
||||||
|
|
||||||
assertEquals(14, list.size());
|
|
||||||
|
|
||||||
Episode first = list.get(0);
|
Episode first = list.get(0);
|
||||||
assertEquals("Firefly", first.getSeriesName());
|
assertEquals("Firefly", first.getSeriesName());
|
||||||
|
@ -122,12 +118,6 @@ public class TheTVDBClientTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getEpisodeListLinkSingleSeason() {
|
|
||||||
assertEquals("http://www.thetvdb.com/?tab=season&seriesid=73965&seasonid=6749", thetvdb.getEpisodeListLink(new TheTVDBSearchResult("Roswell", 73965), 3).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMirror() throws Exception {
|
public void getMirror() throws Exception {
|
||||||
assertNotNull(thetvdb.getMirror(MirrorType.XML));
|
assertNotNull(thetvdb.getMirror(MirrorType.XML));
|
||||||
|
@ -153,15 +143,15 @@ public class TheTVDBClientTest {
|
||||||
public void lookupByID() throws Exception {
|
public void lookupByID() throws Exception {
|
||||||
TheTVDBSearchResult series = thetvdb.lookupByID(78874, Locale.ENGLISH);
|
TheTVDBSearchResult series = thetvdb.lookupByID(78874, Locale.ENGLISH);
|
||||||
assertEquals("Firefly", series.getName());
|
assertEquals("Firefly", series.getName());
|
||||||
assertEquals(70726, series.getSeriesId());
|
assertEquals(78874, series.getSeriesId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lookupByIMDbID() throws Exception {
|
public void lookupByIMDbID() throws Exception {
|
||||||
TheTVDBSearchResult series = thetvdb.lookupByIMDbID(78874, Locale.ENGLISH);
|
TheTVDBSearchResult series = thetvdb.lookupByIMDbID(303461, Locale.ENGLISH);
|
||||||
assertEquals("Firefly", series.getName());
|
assertEquals("Firefly", series.getName());
|
||||||
assertEquals(70726, series.getSeriesId());
|
assertEquals(78874, series.getSeriesId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,9 +169,6 @@ public class TheTVDBClientTest {
|
||||||
assertEquals(310, it.getOverview().length());
|
assertEquals(310, it.getOverview().length());
|
||||||
assertEquals("60", it.getRuntime());
|
assertEquals("60", it.getRuntime());
|
||||||
assertEquals("Chuck", it.getName());
|
assertEquals("Chuck", it.getName());
|
||||||
assertEquals("http://thetvdb.com/banners/graphical/80348-g23.jpg", it.getBannerUrl().toString());
|
|
||||||
assertEquals("http://thetvdb.com/banners/fanart/original/80348-51.jpg", it.getFanartUrl().toString());
|
|
||||||
assertEquals("http://thetvdb.com/banners/posters/80348-16.jpg", it.getPosterUrl().toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue