1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-04 16:35:08 -05:00

+ Support episode SortOrder

This commit is contained in:
Reinhard Pointner 2012-02-13 09:54:57 +00:00
parent 05417b1b39
commit f2e07377ef
28 changed files with 277 additions and 337 deletions

View File

@ -28,6 +28,9 @@ public class ArgumentBean {
@Option(name = "--db", usage = "Episode/Movie database", metaVar = "[TVRage, AniDB, TheTVDB] or [OpenSubtitles, TheMovieDB]")
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")
public String format;

View File

@ -43,7 +43,7 @@ public class ArgumentProcessor {
try {
// print episode info
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);
}
return 0;
@ -69,7 +69,7 @@ public class ArgumentProcessor {
}
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) {

View File

@ -9,24 +9,24 @@ import java.util.List;
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> getMissingSubtitles(Collection<File> files, String query, String lang, String output, String encoding, boolean strict) throws Exception;
boolean check(Collection<File> files) 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;
}

View File

@ -66,6 +66,7 @@ import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.MovieIdentificationService;
import net.sourceforge.filebot.web.MoviePart;
import net.sourceforge.filebot.web.SearchResult;
import net.sourceforge.filebot.web.SortOrder;
import net.sourceforge.filebot.web.SubtitleDescriptor;
import net.sourceforge.filebot.web.SubtitleProvider;
import net.sourceforge.filebot.web.VideoHashSubtitleService;
@ -74,7 +75,7 @@ import net.sourceforge.filebot.web.VideoHashSubtitleService;
public class CmdlineOperations implements CmdlineInterface {
@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;
Locale locale = getLanguage(languageName).toLocale();
@ -85,7 +86,7 @@ public class CmdlineOperations implements CmdlineInterface {
if (getEpisodeListProvider(db) != null) {
// 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) {
@ -121,14 +122,14 @@ public class CmdlineOperations implements CmdlineInterface {
CLILogger.finest(format("Filename pattern: [%.02f] SxE, [%.02f] CWS", sxe / max, cws / max));
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 {
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()));
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);
// fetch episode data
Set<Episode> episodes = fetchEpisodeSet(db, seriesNames, locale, strict);
Set<Episode> episodes = fetchEpisodeSet(db, seriesNames, sortOrder, locale, strict);
if (episodes.size() > 0) {
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>>>();
// detect series names and create episode list fetch tasks
@ -223,7 +224,7 @@ public class CmdlineOperations implements CmdlineInterface {
List<Episode> episodes = new ArrayList<Episode>();
for (SearchResult it : selectedSearchResults) {
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());
}
@ -862,16 +863,17 @@ public class CmdlineOperations implements CmdlineInterface {
@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
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
EpisodeListProvider service = (db == null) ? TVRage : getEpisodeListProvider(db);
SortOrder sortOrder = SortOrder.forName(sortOrderName);
Locale locale = getLanguage(languageName).toLocale();
SearchResult hit = selectSearchResult(query, service.search(query, locale), false).get(0);
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);
episodes.add(name);
}

View File

@ -183,7 +183,7 @@ List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> o
// CLI bindings
def rename(args) { args = _defaults(args)
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)
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.format = args.format ?: _args.format
args.db = args.db ?: _args.db
args.order = args.order ?: _args.order
args.lang = args.lang ?: _args.lang
args.output = args.output ?: _args.output
args.encoding = args.encoding ?: _args.encoding

View File

@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui.episodelist;
import static net.sourceforge.filebot.ui.episodelist.SeasonSpinnerModel.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
@ -21,6 +22,7 @@ import java.util.Locale;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JSpinner;
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.EpisodeListProvider;
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.ui.LabelProvider;
import net.sourceforge.tuned.ui.SelectButton;
@ -54,8 +58,9 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
private SeasonSpinnerModel seasonSpinnerModel = new SeasonSpinnerModel();
private LanguageComboBox languageComboBox = new LanguageComboBox(this, Language.getLanguage("en"));
private JComboBox sortOrderComboBox = new JComboBox(SortOrder.values());
public EpisodeListPanel() {
historyPanel.setColumnHeader(0, "Show");
historyPanel.setColumnHeader(1, "Number of Episodes");
@ -67,8 +72,9 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
seasonSpinner.setMinimumSize(seasonSpinner.getPreferredSize());
// add after text field
add(seasonSpinner, "gap indent", 1);
add(languageComboBox, "gap indent+5", 2);
add(seasonSpinner, "sgy combo, gap indent", 1);
add(sortOrderComboBox, "sgy combo, gap rel", 2);
add(languageComboBox, "sgy combo, gap indent+5", 3);
// add after tabbed pane
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));
}
@Override
protected EpisodeListProvider[] getSearchEngines() {
return WebServices.getEpisodeListProviders();
}
@Override
protected LabelProvider<EpisodeListProvider> getSearchEngineLabelProvider() {
return SimpleLabelProvider.forClass(EpisodeListProvider.class);
}
@Override
protected Settings getSettings() {
return Settings.forPackage(EpisodeListPanel.class);
}
@Override
protected EpisodeListRequestProcessor createRequestProcessor() {
EpisodeListProvider provider = searchTextField.getSelectButton().getSelectedValue();
String text = searchTextField.getText().trim();
int season = seasonSpinnerModel.getSeason();
SortOrder order = (SortOrder) sortOrderComboBox.getSelectedItem();
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() {
public void propertyChange(PropertyChangeEvent evt) {
@ -123,7 +130,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
}
};
private class SpinSeasonAction extends AbstractAction {
public SpinSeasonAction(int spin) {
@ -131,13 +138,13 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
putValue("spin", spin);
}
public void actionPerformed(ActionEvent e) {
seasonSpinnerModel.spin((Integer) getValue("spin"));
}
}
private class SelectedTabExportHandler implements FileExportHandler {
/**
@ -154,7 +161,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
}
}
@Override
public boolean canExport() {
FileExportHandler handler = getExportHandler();
@ -165,13 +172,13 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
return handler.canExport();
}
@Override
public void export(File file) throws IOException {
getExportHandler().export(file);
}
@Override
public String getDefaultFileName() {
return getExportHandler().getDefaultFileName();
@ -179,75 +186,61 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
}
protected static class EpisodeListRequest extends Request {
private final EpisodeListProvider provider;
private final int season;
private final Locale language;
public final EpisodeListProvider provider;
public final int season;
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);
this.provider = provider;
this.season = season;
this.order = order;
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> {
public EpisodeListRequestProcessor(EpisodeListRequest request) {
super(request, new EpisodeListTab());
}
@Override
public Collection<SearchResult> search() throws Exception {
return request.getProvider().search(request.getSearchText(), request.getLanguage());
return request.provider.search(request.getSearchText(), request.language);
}
@Override
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)
episodes = request.getProvider().getEpisodeList(getSearchResult(), request.getSeason(), request.getLanguage());
else
episodes = request.getProvider().getEpisodeList(getSearchResult(), request.getLanguage());
if (request.season != ALL_SEASONS) {
List<Episode> episodeForSeason = filterBySeason(episodes, request.season);
if (episodeForSeason.isEmpty()) {
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;
}
@Override
public URI getLink() {
if (request.getSeason() != ALL_SEASONS) {
return request.getProvider().getEpisodeListLink(getSearchResult(), request.getSeason());
}
return request.getProvider().getEpisodeListLink(getSearchResult());
return request.provider.getEpisodeListLink(getSearchResult());
}
@Override
public void process(Collection<Episode> 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);
}
@Override
public String getStatusMessage(Collection<Episode> result) {
return (result.isEmpty()) ? "No episodes found" : String.format("%d episodes", result.size());
}
@Override
public EpisodeListTab getComponent() {
return (EpisodeListTab) super.getComponent();
}
@Override
public String getTitle() {
if (request.getSeason() == ALL_SEASONS)
if (request.season == ALL_SEASONS)
return super.getTitle();
// 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
public Icon getIcon() {
return request.getProvider().getIcon();
return request.provider.getIcon();
}
@Override
protected void configureSelectDialog(SelectDialog<SearchResult> selectDialog) {
super.configureSelectDialog(selectDialog);
@ -293,7 +286,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
}
protected static class EpisodeListTab extends FileBotList<Episode> {
public EpisodeListTab() {
@ -311,14 +304,14 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
}
protected static class EpisodeListExportHandler extends FileBotListExportHandler implements ClipboardHandler {
public EpisodeListExportHandler(FileBotList<Episode> list) {
super(list);
}
@Override
public Transferable createTransferable(JComponent c) {
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);
}
@Override
public void exportToClipboard(JComponent c, Clipboard clipboard, int action) throws IllegalStateException {
Object[] selection = list.getListComponent().getSelectedValues();

View File

@ -8,9 +8,10 @@ import java.util.List;
import java.util.Locale;
import net.sourceforge.filebot.similarity.Match;
import net.sourceforge.filebot.web.SortOrder;
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;
}

View File

@ -43,6 +43,7 @@ import net.sourceforge.filebot.ui.SelectDialog;
import net.sourceforge.filebot.web.Episode;
import net.sourceforge.filebot.web.EpisodeListProvider;
import net.sourceforge.filebot.web.SearchResult;
import net.sourceforge.filebot.web.SortOrder;
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>>>();
// detect series names and create episode list fetch tasks
@ -135,7 +136,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
SearchResult selectedSearchResult = selectSearchResult(query, results, parent);
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());
return episodes;
@ -168,9 +169,9 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
@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
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
List<Callable<List<Match<File, ?>>>> taskPerFolder = new ArrayList<Callable<List<Match<File, ?>>>>();
@ -192,7 +193,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
@Override
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();
// detect series name and fetch episode list
@ -226,7 +227,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
if (names.size() > 0) {
// only allow one fetch session at a time so later requests can make use of cached results
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) {
// only allow one fetch session at a time so later requests can make use of cached results
synchronized (providerLock) {
episodes = fetchEpisodeSet(input, locale, parent);
episodes = fetchEpisodeSet(input, sortOrder, locale, parent);
}
}
}

View File

@ -43,6 +43,7 @@ import net.sourceforge.filebot.ui.SelectDialog;
import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.MovieIdentificationService;
import net.sourceforge.filebot.web.MoviePart;
import net.sourceforge.filebot.web.SortOrder;
class MovieHashMatcher implements AutoCompleteMatcher {
@ -56,7 +57,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
@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
List<File> movieFiles = filter(files, VIDEO_FILES);

View File

@ -25,13 +25,17 @@ import javax.swing.Action;
import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import javax.swing.border.CompoundBorder;
import javax.swing.border.TitledBorder;
import ca.odell.glazedlists.ListSelection;
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.MovieFormat;
import net.sourceforge.filebot.web.MovieIdentificationService;
import net.sourceforge.filebot.web.SortOrder;
import net.sourceforge.tuned.ExceptionUtilities;
import net.sourceforge.tuned.PreferencesMap.PreferencesEntry;
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> 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> persistentPreferredEpisodeOrder = Settings.forPackage(RenamePanel.class).entry("rename.episode.order").defaultValue("Airdate");
public RenamePanel() {
namesList.setTitle("New Names");
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");
}
protected ActionPopup createFetchPopup() {
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.availableLanguages()); // then others
JList message = new JList(languages.toArray());
message.setCellRenderer(new DefaultListCellRenderer() {
JComboBox orderCombo = new JComboBox(SortOrder.values());
JList languageList = new JList(languages.toArray());
languageList.setCellRenderer(new DefaultListCellRenderer() {
@Override
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) {
if (language.getCode().equals(persistentPreferredLanguage.getValue())) {
message.setSelectedValue(language, true);
languageList.setSelectedValue(language, true);
break;
}
}
JOptionPane pane = new JOptionPane(new JScrollPane(message), PLAIN_MESSAGE, OK_CANCEL_OPTION);
pane.createDialog(getWindowAncestor(RenamePanel.this), "Language Preference").setVisible(true);
JScrollPane spLanguageList = new JScrollPane(languageList);
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)) {
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;
}
protected ActionPopup createSettingsPopup() {
ActionPopup actionPopup = new ActionPopup("Rename Options", ResourceManager.getIcon("action.rename.small"));
@ -269,7 +290,7 @@ public class RenamePanel extends JComponent {
return actionPopup;
}
protected final Action showPopupAction = new AbstractAction("Show Popup") {
@Override
@ -284,18 +305,18 @@ public class RenamePanel extends JComponent {
}
};
protected class PreserveExtensionAction extends AbstractAction {
private final boolean activate;
private PreserveExtensionAction(boolean activate, String name, Icon icon) {
super(name, icon);
this.activate = activate;
}
@Override
public void actionPerformed(ActionEvent evt) {
renameModel.setPreserveExtension(activate);
@ -311,12 +332,12 @@ public class RenamePanel extends JComponent {
}
}
protected class AutoCompleteAction extends AbstractAction {
private final AutoCompleteMatcher matcher;
public AutoCompleteAction(String name, Icon icon, AutoCompleteMatcher matcher) {
super(name, icon);
@ -333,7 +354,7 @@ public class RenamePanel extends JComponent {
});
}
@Override
public void actionPerformed(final ActionEvent evt) {
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>() {
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 boolean autodetection = !isShiftDown(evt); // skip name auto-detection if SHIFT is pressed
@Override
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
for (Match<File, ?> match : matches) {
@ -365,7 +387,7 @@ public class RenamePanel extends JComponent {
return matches;
}
@Override
protected void done() {
try {

View File

@ -2,8 +2,6 @@
package net.sourceforge.filebot.web;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import java.io.Serializable;
import java.util.Arrays;
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<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 {
@ -56,40 +54,22 @@ public abstract class AbstractEpisodeListProvider implements EpisodeListProvider
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();
List<Episode> episodes = (cache != null) ? cache.getEpisodeList(searchResult, locale) : null;
List<Episode> episodes = (cache != null) ? cache.getEpisodeList(searchResult, sortOrder, locale) : null;
if (episodes != null) {
return episodes;
}
// perform actual search
episodes = fetchEpisodeList(searchResult, locale);
episodes = fetchEpisodeList(searchResult, sortOrder, locale);
// cache results and return
return (cache != null) ? cache.putEpisodeList(searchResult, 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;
return (cache != null) ? cache.putEpisodeList(searchResult, sortOrder, locale, episodes) : episodes;
}
@ -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 {
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) {
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 {
Element element = cache.get(new Key(id, key, locale));
Element element = cache.get(new Key(id, key, sortOrder, locale));
if (element != null) {
return Arrays.asList((Episode[]) element.getValue());
}

View File

@ -96,7 +96,7 @@ public class AnidbClient extends AbstractEpisodeListProvider {
@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;
// 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
public URI getEpisodeListLink(SearchResult searchResult) {
int aid = ((AnidbSearchResult) searchResult).getAnimeId();
try {
return new URI("http", host, "/a" + aid, null);
return new URI("http", host, "/a" + ((AnidbSearchResult) searchResult).getAnimeId(), null);
} catch (URISyntaxException 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 {
URL url = new URL("http", host, "/api/animetitles.dat.gz");
ResultCache cache = getCache();

View File

@ -13,28 +13,22 @@ public interface EpisodeListProvider {
public String getName();
public Icon getIcon();
public boolean hasSingleSeasonSupport();
public boolean hasLocaleSupport();
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, int season, Locale locale) throws Exception;
public List<Episode> getEpisodeList(SearchResult searchResult, SortOrder order, Locale locale) throws Exception;
public URI getEpisodeListLink(SearchResult searchResult);
public URI getEpisodeListLink(SearchResult searchResult, int season);
}

View File

@ -15,13 +15,13 @@ public final class EpisodeUtilities {
return name.replaceAll("[(]([^)]*)[)]", "").trim();
}
public static List<Episode> filterBySeason(Iterable<Episode> episodes, int season) {
List<Episode> results = new ArrayList<Episode>(25);
// filter given season from all seasons
for (Episode episode : episodes) {
if (season == episode.getSeason()) {
if (episode.getSeason() != null && season == episode.getSeason()) {
results.add(episode);
}
}
@ -29,7 +29,7 @@ public final class EpisodeUtilities {
return results;
}
public static int getLastSeason(Iterable<Episode> episodes) {
int lastSeason = 0;
@ -43,12 +43,12 @@ public final class EpisodeUtilities {
return lastSeason;
}
public static void sortEpisodes(List<Episode> episodes) {
Collections.sort(episodes, episodeComparator());
}
public static Comparator<Episode> episodeComparator() {
return new Comparator<Episode>() {
@ -69,7 +69,7 @@ public final class EpisodeUtilities {
return compareValue(a.getTitle(), b.getTitle());
}
private <T> int compareValue(Comparable<T> o1, T o2) {
if (o1 == null && o2 == null)
return 0;
@ -83,7 +83,7 @@ public final class EpisodeUtilities {
};
}
private EpisodeUtilities() {
throw new UnsupportedOperationException();
}

View File

@ -15,8 +15,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -78,7 +76,6 @@ public class IMDbClient implements MovieIdentificationService {
results.add(new Movie(name, Integer.parseInt(year), getImdbId(href)));
} catch (Exception e) {
// ignore illegal movies (TV Shows, Videos, Video Games, etc)
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getClass().getName() + ": " + e.getMessage());
}
}

View File

@ -115,7 +115,7 @@ public class SerienjunkiesClient extends AbstractEpisodeListProvider {
@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;
// fetch episode data
@ -162,18 +162,7 @@ public class SerienjunkiesClient extends AbstractEpisodeListProvider {
@Override
public URI getEpisodeListLink(SearchResult searchResult) {
return getEpisodeListLink(searchResult, "alle-serien-staffeln");
}
@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));
return URI.create(String.format("http://www.serienjunkies.de/%s/alle-serien-staffeln.html", ((SerienjunkiesSearchResult) searchResult).getLink()));
}

View File

@ -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());
}
}

View File

@ -27,25 +27,25 @@ public class TVRageClient extends AbstractEpisodeListProvider {
private final String host = "services.tvrage.com";
@Override
public String getName() {
return "TVRage";
}
@Override
public Icon getIcon() {
return ResourceManager.getIcon("search.tvrage");
}
@Override
public ResultCache getCache() {
return new ResultCache(host, CacheManager.getInstance().getCache("web-datasource"));
}
@Override
public List<SearchResult> fetchSearchResult(String query, Locale locale) throws IOException, SAXException {
URL searchUrl = new URL("http", host, "/feeds/full_search.php?show=" + encode(query));
@ -65,9 +65,9 @@ public class TVRageClient extends AbstractEpisodeListProvider {
return searchResults;
}
@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;
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));
} else {
// 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));
}
}
@ -105,60 +110,47 @@ public class TVRageClient extends AbstractEpisodeListProvider {
return episodes;
}
@Override
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 {
protected int showId;
protected String link;
protected TVRageSearchResult() {
// used by serializer
}
public TVRageSearchResult(String name, int showId, String link) {
super(name);
this.showId = showId;
this.link = link;
}
public int getSeriesId() {
return showId;
}
public String getLink() {
return link;
}
@Override
public int hashCode() {
return showId;
}
@Override
public boolean equals(Object object) {
if (object instanceof TVRageSearchResult) {

View File

@ -109,9 +109,8 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
@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;
Document seriesRecord = getSeriesRecord(series, language);
// 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);
Date airdate = Date.parse(getTextContent("FirstAired", node), "yyyy-MM-dd");
// prefer DVD SxE numbers if available
Integer seasonNumber;
Integer episodeNumber;
try {
seasonNumber = new Integer(dvdSeasonNumber);
episodeNumber = new Float(dvdEpisodeNumber).intValue();
} catch (Exception e) {
seasonNumber = getIntegerContent("SeasonNumber", node);
episodeNumber = getIntegerContent("EpisodeNumber", node);
}
// default numbering
Integer episodeNumber = getIntegerContent("EpisodeNumber", node);
Integer seasonNumber = getIntegerContent("SeasonNumber", node);
if (seasonNumber == null || seasonNumber == 0) {
// 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));
} else {
// 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));
}
}
@ -237,28 +242,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
@Override
public URI getEpisodeListLink(SearchResult searchResult) {
int seriesId = ((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;
return URI.create("http://" + host + "/?tab=seasonall&id=" + ((TheTVDBSearchResult) searchResult).getSeriesId());
}

View File

@ -8,8 +8,6 @@ import java.io.File;
import org.junit.Test;
import net.sourceforge.filebot.media.ReleaseInfo;
public class ReleaseInfoTest {
@ -18,10 +16,10 @@ public class ReleaseInfoTest {
ReleaseInfo info = new ReleaseInfo();
File f = new File("Jurassic.Park[1993]DvDrip-aXXo.avi");
assertEquals("DvDrip", info.getVideoSource(f));
assertEquals("DVDRip", info.getVideoSource(f));
}
@Test
public void getReleaseGroup() throws Exception {
ReleaseInfo info = new ReleaseInfo();

View File

@ -13,7 +13,7 @@ public class SeriesNameMatcherTest {
private static SeriesNameMatcher matcher = new SeriesNameMatcher();
@Test
public void whitelist() {
// ignore recurring word sequences when matching episode patterns
@ -22,7 +22,7 @@ public class SeriesNameMatcherTest {
assertArrayEquals(new String[] { "Test 101" }, matcher.matchAll(names).toArray());
}
@Test
public void threshold() {
// ignore recurring word sequences when matching episode patterns
@ -31,16 +31,16 @@ public class SeriesNameMatcherTest {
assertArrayEquals(new String[] { "Test" }, matcher.matchAll(names).toArray());
}
@Test
public void matchBeforeSeasonEpisodePattern() {
assertEquals("The Test", matcher.matchByEpisodeIdentifier("The Test - 1x01"));
// real world test
assertEquals("Mushishi", matcher.matchByEpisodeIdentifier("[niizk]_Mushishi_-_01_-_The_Green_Gathering"));
assertEquals("Mushishi", matcher.matchByEpisodeIdentifier("[niizk]_Mushishi_-_1x01_-_The_Green_Gathering"));
}
@Test
public void normalize() {
// non-letter and non-digit characters
@ -53,7 +53,7 @@ public class SeriesNameMatcherTest {
assertEquals("strawhat Luffy", matcher.normalize("(strawhat [Luffy (#Monkey)"));
}
@Test
public void firstCommonSequence() {
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));
}
@Test
public void firstCharacterCaseBalance() {
SeriesNameCollection n = new SeriesNameCollection();

View File

@ -32,7 +32,7 @@ public class AnidbClientTest {
*/
private static AnidbSearchResult princessTutuSearchResult;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
monsterSearchResult = new AnidbSearchResult(1539, "Monster", null);
@ -40,10 +40,10 @@ public class AnidbClientTest {
princessTutuSearchResult = new AnidbSearchResult(516, "Princess Tutu", null);
}
private AnidbClient anidb = new AnidbClient("filebot", 2);
@Test
public void search() throws Exception {
List<SearchResult> results = anidb.search("one piece");
@ -53,7 +53,7 @@ public class AnidbClientTest {
assertEquals(69, result.getAnimeId());
}
@Test
public void searchJapanese() throws Exception {
List<SearchResult> results = anidb.search("ワンピース", Locale.JAPANESE);
@ -63,7 +63,7 @@ public class AnidbClientTest {
assertEquals(69, result.getAnimeId());
}
@Test
public void searchNoMatch() throws Exception {
List<SearchResult> results = anidb.search("i will not find anything for this query string");
@ -71,7 +71,7 @@ public class AnidbClientTest {
assertTrue(results.isEmpty());
}
@Test
public void searchTitleAlias() throws Exception {
// 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());
}
@Test
public void getEpisodeListAll() throws Exception {
List<Episode> list = anidb.getEpisodeList(monsterSearchResult);
@ -100,7 +100,7 @@ public class AnidbClientTest {
assertEquals("2004-04-07", first.airdate().toString());
}
@Test
public void getEpisodeListAllShortLink() throws Exception {
List<Episode> list = anidb.getEpisodeList(twelvekingdomsSearchResult);
@ -118,16 +118,16 @@ public class AnidbClientTest {
assertEquals("2002-04-09", first.airdate().toString());
}
@Test
public void getEpisodeListEncoding() throws Exception {
assertEquals("Raven Princess - An der schönen blauen Donau", anidb.getEpisodeList(princessTutuSearchResult).get(6).getTitle());
}
@Test
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);
assertEquals("モンスター", last.getSeriesName());
@ -139,19 +139,19 @@ public class AnidbClientTest {
assertEquals("2005-09-28", last.airdate().toString());
}
@Test
public void getEpisodeListTrimRecap() throws Exception {
assertEquals("Sea God of the East, Azure Sea of the West - Transition Chapter", anidb.getEpisodeList(twelvekingdomsSearchResult).get(44).getTitle());
}
@Test
public void getEpisodeListLink() throws Exception {
assertEquals("http://anidb.net/a1539", anidb.getEpisodeListLink(monsterSearchResult).toURL().toString());
}
@BeforeClass
@AfterClass
public static void clearCache() {

View File

@ -18,7 +18,6 @@ public class IMDbClientTest {
public void searchMovie() throws Exception {
List<Movie> results = imdb.searchMovie("Avatar", null);
assertEquals(26, results.size());
Movie movie = (Movie) results.get(0);
assertEquals("Avatar", movie.getName());

View File

@ -38,7 +38,7 @@ public class OpenSubtitlesXmlRpcTest {
Movie sample = (Movie) list.get(0);
// check sample entry
assertEquals("\"Babylon 5\"", sample.getName());
assertEquals("Babylon 5", sample.getName());
assertEquals(1994, sample.getYear());
assertEquals(105946, sample.getImdbId());
}

View File

@ -21,14 +21,14 @@ public class SublightSubtitleClientTest {
private static SublightSubtitleClient client = new SublightSubtitleClient(getApplicationName(), getApplicationProperty("sublight.apikey"));
@BeforeClass
public static void login() {
// login manually
client.login();
}
@Test
public void search() {
List<SearchResult> list = client.search("babylon 5");
@ -43,21 +43,19 @@ public class SublightSubtitleClientTest {
assertEquals(8, list.size());
}
@Test
public void getSubtitleListEnglish() {
List<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Heroes", 2006, 813715), "English");
SubtitleDescriptor sample = list.get(0);
assertTrue(sample.getName().startsWith("Heroes"));
assertEquals("English", sample.getLanguageName());
// check size
assertTrue(list.size() > 45);
}
@Test
public void getSubtitleListAllLanguages() {
List<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), null);
@ -71,7 +69,7 @@ public class SublightSubtitleClientTest {
assertTrue(list.size() > 15);
}
@Test
public void getSubtitleListVideoHash() throws Exception {
List<Subtitle> list = client.getSubtitleList("001c6e0000320458004ee6f6859e5b7844767d44336e5624edbb", null, null, "English");
@ -82,7 +80,7 @@ public class SublightSubtitleClientTest {
assertEquals(true, sample.isIsLinked());
}
@Test
public void getZipArchive() throws Exception {
Subtitle subtitle = new Subtitle();
@ -103,7 +101,7 @@ public class SublightSubtitleClientTest {
}
}
@AfterClass
public static void logout() {
// logout manually

View File

@ -30,7 +30,7 @@ public class SubsceneSubtitleClientTest {
@BeforeClass
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"));
}
@ -64,12 +64,11 @@ public class SubsceneSubtitleClientTest {
@Test
public void getSubtitleListSearchResult() throws Exception {
List<SubtitleDescriptor> subtitleList = subscene.getSubtitleList(twinpeaksSearchResult, "Italian");
assertEquals(1, subtitleList.size());
assertEquals(10, subtitleList.size());
SubtitleDescriptor subtitle = subtitleList.get(0);
assertEquals("Twin Peaks - First Season", subtitle.getName());
assertEquals("Italian", subtitle.getLanguageName());
assertEquals("zip", subtitle.getType());
}

View File

@ -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");
@Test
public void search() throws Exception {
List<SearchResult> results = tvrage.search("Buffy");
@ -30,13 +30,13 @@ public class TVRageClientTest {
assertEquals(buffySearchResult.getLink(), result.getLink());
}
private TVRageClient tvrage = new TVRageClient();
@Test
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());
@ -51,36 +51,24 @@ public class TVRageClientTest {
assertEquals("2003-05-20", chosen.airdate().toString());
}
@Test
public void getEpisodeListAll() throws Exception {
List<Episode> list = tvrage.getEpisodeList(buffySearchResult);
assertEquals(145, list.size());
assertEquals(144, list.size());
Episode first = list.get(0);
assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
assertEquals("Unaired Pilot", first.getTitle());
assertEquals("0", first.getEpisode().toString());
assertEquals("0", first.getSeason().toString());
assertEquals("Welcome to the Hellmouth (1)", first.getTitle());
assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString());
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
public void getEpisodeListLinkAll() throws Exception {
assertEquals(tvrage.getEpisodeListLink(buffySearchResult).toString(), "http://www.tvrage.com/Buffy_The_Vampire_Slayer/episode_list/all");

View File

@ -83,9 +83,7 @@ public class TheTVDBClientTest {
@Test
public void getEpisodeListSingleSeason() throws Exception {
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Wonderfalls", 78845), 1);
assertEquals(14, list.size());
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Wonderfalls", 78845));
Episode first = list.get(0);
@ -101,9 +99,7 @@ public class TheTVDBClientTest {
@Test
public void getEpisodeListNumbering() throws Exception {
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Firefly", 78874), 1);
assertEquals(14, list.size());
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Firefly", 78874), SortOrder.DVD, Locale.ENGLISH);
Episode first = list.get(0);
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
public void getMirror() throws Exception {
assertNotNull(thetvdb.getMirror(MirrorType.XML));
@ -153,15 +143,15 @@ public class TheTVDBClientTest {
public void lookupByID() throws Exception {
TheTVDBSearchResult series = thetvdb.lookupByID(78874, Locale.ENGLISH);
assertEquals("Firefly", series.getName());
assertEquals(70726, series.getSeriesId());
assertEquals(78874, series.getSeriesId());
}
@Test
public void lookupByIMDbID() throws Exception {
TheTVDBSearchResult series = thetvdb.lookupByIMDbID(78874, Locale.ENGLISH);
TheTVDBSearchResult series = thetvdb.lookupByIMDbID(303461, Locale.ENGLISH);
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("60", it.getRuntime());
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());
}