1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 16:58:51 -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]") @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;

View File

@ -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) {

View File

@ -9,7 +9,7 @@ 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;
@ -24,7 +24,7 @@ public interface CmdlineInterface {
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;

View File

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

View File

@ -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

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.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,6 +58,7 @@ 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() {
@ -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())));
@ -103,9 +109,10 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
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));
}; };
@ -182,32 +189,19 @@ 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;
}
} }
@ -220,31 +214,30 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
@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());
} }
@ -271,17 +264,17 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
@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();
} }

View File

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

View File

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

View File

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

View File

@ -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,6 +76,7 @@ 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() {
@ -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());
} }
} }
}); });
@ -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) {

View File

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

View File

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

View File

@ -26,15 +26,9 @@ public interface EpisodeListProvider {
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);
} }

View File

@ -21,7 +21,7 @@ public final class EpisodeUtilities {
// 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);
} }
} }

View File

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

View File

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

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

@ -67,7 +67,7 @@ public class TVRageClient extends AbstractEpisodeListProvider {
@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));
} }
} }
@ -108,20 +113,7 @@ public class TVRageClient extends AbstractEpisodeListProvider {
@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);
} }

View File

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

View File

@ -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,7 +16,7 @@ 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));
} }

View File

@ -37,7 +37,7 @@ public class SeriesNameMatcherTest {
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"));
} }

View File

@ -127,7 +127,7 @@ public class AnidbClientTest {
@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());

View File

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

View File

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

View File

@ -49,8 +49,6 @@ public class SublightSubtitleClientTest {
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

View File

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

View File

@ -36,7 +36,7 @@ public class TVRageClientTest {
@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());
@ -56,28 +56,16 @@ public class TVRageClientTest {
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");
} }

View File

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