From bafb33d676d4daf40ab22b36e7fe73527dced4a7 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 22 Sep 2011 12:55:04 +0000 Subject: [PATCH] * simplify classname --- .../sourceforge/filebot/Settings.properties | 2 +- .../filebot/cli/ArgumentProcessor.java | 8 ++--- .../filebot/format/MediaBindingBean.java | 10 +++--- .../filebot/ui/rename/MovieHashMatcher.java | 32 +++++++++---------- .../filebot/ui/rename/RenameAction.java | 3 +- .../filebot/ui/rename/RenamePanel.java | 8 ++--- .../sourceforge/filebot/web/IMDbClient.java | 6 ++-- .../sourceforge/filebot/web/MovieFormat.java | 10 +++--- .../web/MovieIdentificationService.java | 6 ++-- .../sourceforge/filebot/web/MoviePart.java | 4 +-- .../filebot/web/OpenSubtitlesClient.java | 14 ++++---- .../filebot/web/OpenSubtitlesXmlRpc.java | 16 +++++----- .../filebot/web/SublightSubtitleClient.java | 4 +-- .../sourceforge/filebot/web/TMDbClient.java | 22 ++++++------- .../filebot/web/IMDbClientTest.java | 12 +++---- .../filebot/web/OpenSubtitlesXmlRpcTest.java | 14 ++++---- .../web/SublightSubtitleClientTest.java | 6 ++-- .../filebot/web/TMDbClientTest.java | 10 +++--- 18 files changed, 94 insertions(+), 93 deletions(-) diff --git a/source/net/sourceforge/filebot/Settings.properties b/source/net/sourceforge/filebot/Settings.properties index 24d89631..29a69cb3 100644 --- a/source/net/sourceforge/filebot/Settings.properties +++ b/source/net/sourceforge/filebot/Settings.properties @@ -2,7 +2,7 @@ application.name: FileBot application.version: 2.0 -# google analytics +# google analytics analytics.WebPropertyID: UA-25379256-2 # database api keys diff --git a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java index 12728e17..28645047 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java +++ b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java @@ -50,7 +50,7 @@ import net.sourceforge.filebot.vfs.MemoryFile; import net.sourceforge.filebot.web.Episode; import net.sourceforge.filebot.web.EpisodeFormat; import net.sourceforge.filebot.web.EpisodeListProvider; -import net.sourceforge.filebot.web.MovieDescriptor; +import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.MovieIdentificationService; import net.sourceforge.filebot.web.SearchResult; import net.sourceforge.filebot.web.SubtitleDescriptor; @@ -200,12 +200,12 @@ public class ArgumentProcessor { CLILogger.fine(format("Looking up movie by filehash via [%s]", db.getName())); // match movie hashes online - MovieDescriptor[] movieDescriptors = db.getMovieDescriptors(movieFiles, locale); + Movie[] movieDescriptors = db.getMovieDescriptors(movieFiles, locale); // use user query if search by hash did not return any results, only one query for one movie though if (query != null && movieDescriptors.length == 1 && movieDescriptors[0] == null) { CLILogger.fine(format("Looking up movie by query [%s]", query)); - movieDescriptors[0] = (MovieDescriptor) selectSearchResult(query, new ArrayList(db.searchMovie(query, locale)), strict); + movieDescriptors[0] = (Movie) selectSearchResult(query, new ArrayList(db.searchMovie(query, locale)), strict); } // map old files to new paths by applying formatting and validating filenames @@ -213,7 +213,7 @@ public class ArgumentProcessor { for (int i = 0; i < movieFiles.length; i++) { if (movieDescriptors[i] != null) { - MovieDescriptor movie = movieDescriptors[i]; + Movie movie = movieDescriptors[i]; File file = movieFiles[i]; String newName = (format != null) ? format.format(new MediaBindingBean(movie, file)) : movie.toString(); diff --git a/source/net/sourceforge/filebot/format/MediaBindingBean.java b/source/net/sourceforge/filebot/format/MediaBindingBean.java index 9c208feb..6b701908 100644 --- a/source/net/sourceforge/filebot/format/MediaBindingBean.java +++ b/source/net/sourceforge/filebot/format/MediaBindingBean.java @@ -26,7 +26,7 @@ import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind; import net.sourceforge.filebot.web.CachedResource; import net.sourceforge.filebot.web.Date; import net.sourceforge.filebot.web.Episode; -import net.sourceforge.filebot.web.MovieDescriptor; +import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.MoviePart; import net.sourceforge.tuned.FileUtilities; @@ -55,7 +55,7 @@ public class MediaBindingBean { public String getName() { if (infoObject instanceof Episode) return getEpisode().getSeriesName(); - if (infoObject instanceof MovieDescriptor) + if (infoObject instanceof Movie) return getMovie().getName(); return null; @@ -66,7 +66,7 @@ public class MediaBindingBean { public Integer getYear() { if (infoObject instanceof Episode) return getEpisode().airdate().getYear(); - if (infoObject instanceof MovieDescriptor) + if (infoObject instanceof Movie) return getMovie().getYear(); return null; @@ -303,8 +303,8 @@ public class MediaBindingBean { @Define("movie") - public MovieDescriptor getMovie() { - return (MovieDescriptor) infoObject; + public Movie getMovie() { + return (Movie) infoObject; } diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index 28d13d0b..e15eb7dc 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -33,7 +33,7 @@ import javax.swing.SwingUtilities; import net.sourceforge.filebot.Analytics; import net.sourceforge.filebot.similarity.Match; import net.sourceforge.filebot.ui.SelectDialog; -import net.sourceforge.filebot.web.MovieDescriptor; +import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.MovieIdentificationService; import net.sourceforge.filebot.web.MoviePart; @@ -54,14 +54,14 @@ class MovieHashMatcher implements AutoCompleteMatcher { File[] movieFiles = filter(files, VIDEO_FILES).toArray(new File[0]); // match movie hashes online - MovieDescriptor[] movieByFileHash = service.getMovieDescriptors(movieFiles, locale); + Movie[] movieByFileHash = service.getMovieDescriptors(movieFiles, locale); // map movies to (possibly multiple) files (in natural order) - Map> filesByMovie = new HashMap>(); + Map> filesByMovie = new HashMap>(); // map all files by movie for (int i = 0; i < movieFiles.length; i++) { - MovieDescriptor movie = movieByFileHash[i]; + Movie movie = movieByFileHash[i]; // unknown hash, try via imdb id from nfo file if (movie == null || !autodetect) { @@ -91,20 +91,20 @@ class MovieHashMatcher implements AutoCompleteMatcher { // collect all File/MoviePart matches List> matches = new ArrayList>(); - for (Entry> entry : filesByMovie.entrySet()) { - MovieDescriptor movie = entry.getKey(); + for (Entry> entry : filesByMovie.entrySet()) { + Movie movie = entry.getKey(); int partIndex = 0; int partCount = entry.getValue().size(); // add all movie parts for (File file : entry.getValue()) { - MovieDescriptor part = movie; + Movie part = movie; if (partCount > 1) { part = new MoviePart(movie, ++partIndex, partCount); } - matches.add(new Match(file, part)); + matches.add(new Match(file, part)); } } @@ -163,11 +163,11 @@ class MovieHashMatcher implements AutoCompleteMatcher { } - protected MovieDescriptor grabMovieName(File movieFile, Locale locale, boolean autodetect, MovieDescriptor... suggestions) throws Exception { - List options = new ArrayList(); + protected Movie grabMovieName(File movieFile, Locale locale, boolean autodetect, Movie... suggestions) throws Exception { + List options = new ArrayList(); // add default value if any - for (MovieDescriptor it : suggestions) { + for (Movie it : suggestions) { if (it != null) { options.add(it); } @@ -175,7 +175,7 @@ class MovieHashMatcher implements AutoCompleteMatcher { // try to grep imdb id from nfo files for (int imdbid : grepImdbId(movieFile.getParentFile().listFiles(getDefaultFilter("application/nfo")))) { - MovieDescriptor movie = service.getMovieDescriptor(imdbid, locale); + Movie movie = service.getMovieDescriptor(imdbid, locale); if (movie != null) { options.add(movie); @@ -205,18 +205,18 @@ class MovieHashMatcher implements AutoCompleteMatcher { } - protected MovieDescriptor selectMovie(final List options) throws Exception { + protected Movie selectMovie(final List options) throws Exception { if (options.size() == 1) { return options.get(0); } // show selection dialog on EDT - final RunnableFuture showSelectDialog = new FutureTask(new Callable() { + final RunnableFuture showSelectDialog = new FutureTask(new Callable() { @Override - public MovieDescriptor call() throws Exception { + public Movie call() throws Exception { // multiple results have been found, user must select one - SelectDialog selectDialog = new SelectDialog(null, options); + SelectDialog selectDialog = new SelectDialog(null, options); selectDialog.getHeaderLabel().setText("Select Movie:"); selectDialog.getCancelAction().putValue(Action.NAME, "Ignore"); diff --git a/source/net/sourceforge/filebot/ui/rename/RenameAction.java b/source/net/sourceforge/filebot/ui/rename/RenameAction.java index ed5dd75d..3c24e5fd 100644 --- a/source/net/sourceforge/filebot/ui/rename/RenameAction.java +++ b/source/net/sourceforge/filebot/ui/rename/RenameAction.java @@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui.rename; import static java.util.Collections.*; +import static net.sourceforge.filebot.Settings.*; import static net.sourceforge.filebot.ui.NotificationLogging.*; import static net.sourceforge.tuned.FileUtilities.*; import static net.sourceforge.tuned.ui.TunedUtilities.*; @@ -94,7 +95,7 @@ class RenameAction extends AbstractAction { HistorySpooler.getInstance().append(renameLog); for (Class it : new HashSet(types)) { - Analytics.trackEvent("GUI", "Rename", it.getSimpleName(), frequency(types, it)); + Analytics.trackEvent(getApplicationName(), "Rename", it.getSimpleName(), frequency(types, it)); } } } diff --git a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java index 0fe39d1d..f3e2e794 100644 --- a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java @@ -46,7 +46,7 @@ import net.sourceforge.filebot.ui.rename.RenameModel.FormattedFuture; import net.sourceforge.filebot.web.Episode; import net.sourceforge.filebot.web.EpisodeFormat; import net.sourceforge.filebot.web.EpisodeListProvider; -import net.sourceforge.filebot.web.MovieDescriptor; +import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.MovieFormat; import net.sourceforge.filebot.web.MovieIdentificationService; import net.sourceforge.tuned.ExceptionUtilities; @@ -87,7 +87,7 @@ public class RenamePanel extends JComponent { renameModel.useFormatter(File.class, new FileNameFormatter(renameModel.preserveExtension())); // movie formatter - renameModel.useFormatter(MovieDescriptor.class, new MovieFormatter()); + renameModel.useFormatter(Movie.class, new MovieFormatter()); try { // restore custom episode formatter @@ -98,7 +98,7 @@ public class RenamePanel extends JComponent { try { // restore custom movie formatter - renameModel.useFormatter(MovieDescriptor.class, new ExpressionFormatter(persistentMovieFormat.getValue(), MovieFormat.NameYear, MovieDescriptor.class)); + renameModel.useFormatter(Movie.class, new ExpressionFormatter(persistentMovieFormat.getValue(), MovieFormat.NameYear, Movie.class)); } catch (Exception e) { // illegal format, ignore } @@ -187,7 +187,7 @@ public class RenamePanel extends JComponent { persistentEpisodeFormat.setValue(dialog.getFormat().getExpression()); break; case Movie: - renameModel.useFormatter(MovieDescriptor.class, new ExpressionFormatter(dialog.getFormat().getExpression(), MovieFormat.NameYear, MovieDescriptor.class)); + renameModel.useFormatter(Movie.class, new ExpressionFormatter(dialog.getFormat().getExpression(), MovieFormat.NameYear, Movie.class)); persistentMovieFormat.setValue(dialog.getFormat().getExpression()); break; } diff --git a/source/net/sourceforge/filebot/web/IMDbClient.java b/source/net/sourceforge/filebot/web/IMDbClient.java index 122c8c86..7b9bf53f 100644 --- a/source/net/sourceforge/filebot/web/IMDbClient.java +++ b/source/net/sourceforge/filebot/web/IMDbClient.java @@ -60,7 +60,7 @@ public class IMDbClient extends AbstractEpisodeListProvider { String year = node.getNextSibling().getTextContent().trim().replaceAll("\\D+", ""); // remove non-number characters String href = getAttribute("href", node); - results.add(new MovieDescriptor(name, Integer.parseInt(year), getImdbId(href))); + results.add(new Movie(name, Integer.parseInt(year), getImdbId(href))); } // we might have been redirected to the movie page @@ -70,7 +70,7 @@ public class IMDbClient extends AbstractEpisodeListProvider { String year = new Scanner(selectString("//H1//SPAN", dom)).useDelimiter("\\D+").next(); String url = selectString("//LINK[@rel='canonical']/@href", dom); - results.add(new MovieDescriptor(name, Integer.parseInt(year), getImdbId(url))); + results.add(new Movie(name, Integer.parseInt(year), getImdbId(url))); } catch (Exception e) { // ignore, we probably got redirected to an error page } @@ -144,7 +144,7 @@ public class IMDbClient extends AbstractEpisodeListProvider { @Override public URI getEpisodeListLink(SearchResult searchResult, int season) { try { - return new URI("http", host, String.format("/title/tt%07d/episodes", ((MovieDescriptor) searchResult).getImdbId()), season > 0 ? String.format("season-%d", season) : null); + return new URI("http", host, String.format("/title/tt%07d/episodes", ((Movie) searchResult).getImdbId()), season > 0 ? String.format("season-%d", season) : null); } catch (URISyntaxException e) { throw new RuntimeException(e); } diff --git a/source/net/sourceforge/filebot/web/MovieFormat.java b/source/net/sourceforge/filebot/web/MovieFormat.java index bc871667..fbddc7f0 100644 --- a/source/net/sourceforge/filebot/web/MovieFormat.java +++ b/source/net/sourceforge/filebot/web/MovieFormat.java @@ -29,7 +29,7 @@ public class MovieFormat extends Format { @Override public StringBuffer format(Object obj, StringBuffer sb, FieldPosition pos) { // format episode object, e.g. Avatar (2009), Part 1 - MovieDescriptor movie = (MovieDescriptor) obj; + Movie movie = (Movie) obj; sb.append(movie.getName()); @@ -56,7 +56,7 @@ public class MovieFormat extends Format { @Override - public MovieDescriptor parseObject(String source, ParsePosition pos) { + public Movie parseObject(String source, ParsePosition pos) { String s = source; Matcher m; @@ -73,7 +73,7 @@ public class MovieFormat extends Format { String name = m.group(1).trim(); int year = Integer.parseInt(m.group(2)); - MovieDescriptor movie = new MovieDescriptor(name, year, -1); + Movie movie = new Movie(name, year, -1); if (partIndex >= 0) { movie = new MoviePart(movie, partIndex, partCount); } @@ -90,8 +90,8 @@ public class MovieFormat extends Format { @Override - public MovieDescriptor parseObject(String source) throws ParseException { - return (MovieDescriptor) super.parseObject(source); + public Movie parseObject(String source) throws ParseException { + return (Movie) super.parseObject(source); } } diff --git a/source/net/sourceforge/filebot/web/MovieIdentificationService.java b/source/net/sourceforge/filebot/web/MovieIdentificationService.java index 95619f0e..36695a07 100644 --- a/source/net/sourceforge/filebot/web/MovieIdentificationService.java +++ b/source/net/sourceforge/filebot/web/MovieIdentificationService.java @@ -17,12 +17,12 @@ public interface MovieIdentificationService { public Icon getIcon(); - public List searchMovie(String query, Locale locale) throws Exception; + public List searchMovie(String query, Locale locale) throws Exception; - public MovieDescriptor getMovieDescriptor(int imdbid, Locale locale) throws Exception; + public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception; - public MovieDescriptor[] getMovieDescriptors(File[] movieFiles, Locale locale) throws Exception; + public Movie[] getMovieDescriptors(File[] movieFiles, Locale locale) throws Exception; } diff --git a/source/net/sourceforge/filebot/web/MoviePart.java b/source/net/sourceforge/filebot/web/MoviePart.java index d9bc707a..0906799f 100644 --- a/source/net/sourceforge/filebot/web/MoviePart.java +++ b/source/net/sourceforge/filebot/web/MoviePart.java @@ -2,13 +2,13 @@ package net.sourceforge.filebot.web; -public class MoviePart extends MovieDescriptor { +public class MoviePart extends Movie { protected final int partIndex; protected final int partCount; - public MoviePart(MovieDescriptor movie, int partIndex, int partCount) { + public MoviePart(Movie movie, int partIndex, int partCount) { super(movie.name, movie.year, movie.imdbId); this.partIndex = partIndex; this.partCount = partCount; diff --git a/source/net/sourceforge/filebot/web/OpenSubtitlesClient.java b/source/net/sourceforge/filebot/web/OpenSubtitlesClient.java index 8553ae48..803ca20d 100644 --- a/source/net/sourceforge/filebot/web/OpenSubtitlesClient.java +++ b/source/net/sourceforge/filebot/web/OpenSubtitlesClient.java @@ -73,7 +73,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS @Override public List getSubtitleList(SearchResult searchResult, String languageName) throws Exception { // singleton array with or empty array - int imdbid = ((MovieDescriptor) searchResult).getImdbId(); + int imdbid = ((Movie) searchResult).getImdbId(); String[] languageFilter = languageName != null ? new String[] { getSubLanguageID(languageName) } : new String[0]; // require login @@ -146,7 +146,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS @Override - public List searchMovie(String query, Locale locale) throws Exception { + public List searchMovie(String query, Locale locale) throws Exception { // require login login(); @@ -155,7 +155,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS @Override - public MovieDescriptor getMovieDescriptor(int imdbid, Locale locale) throws Exception { + public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception { // require login login(); @@ -164,9 +164,9 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS @Override - public MovieDescriptor[] getMovieDescriptors(File[] movieFiles, Locale locale) throws Exception { + public Movie[] getMovieDescriptors(File[] movieFiles, Locale locale) throws Exception { // create result array - MovieDescriptor[] result = new MovieDescriptor[movieFiles.length]; + Movie[] result = new Movie[movieFiles.length]; // compute movie hashes Map indexMap = new HashMap(movieFiles.length); @@ -182,7 +182,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS login(); // dispatch single query for all hashes - for (Entry entry : xmlrpc.checkMovieHash(indexMap.keySet()).entrySet()) { + for (Entry entry : xmlrpc.checkMovieHash(indexMap.keySet()).entrySet()) { int index = indexMap.get(entry.getKey()); result[index] = entry.getValue(); } @@ -193,7 +193,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS @Override public URI getSubtitleListLink(SearchResult searchResult, String languageName) { - MovieDescriptor movie = (MovieDescriptor) searchResult; + Movie movie = (Movie) searchResult; String sublanguageid = "all"; if (languageName != null) { diff --git a/source/net/sourceforge/filebot/web/OpenSubtitlesXmlRpc.java b/source/net/sourceforge/filebot/web/OpenSubtitlesXmlRpc.java index dc2758e2..aface689 100644 --- a/source/net/sourceforge/filebot/web/OpenSubtitlesXmlRpc.java +++ b/source/net/sourceforge/filebot/web/OpenSubtitlesXmlRpc.java @@ -121,11 +121,11 @@ public class OpenSubtitlesXmlRpc { @SuppressWarnings("unchecked") - public List searchMoviesOnIMDB(String query) throws XmlRpcFault { + public List searchMoviesOnIMDB(String query) throws XmlRpcFault { Map response = invoke("SearchMoviesOnIMDB", token, query); List> movieData = (List>) response.get("data"); - List movies = new ArrayList(); + List movies = new ArrayList(); // title pattern Pattern pattern = Pattern.compile("(.+)[(](\\d{4})([/]I+)?[)]"); @@ -139,7 +139,7 @@ public class OpenSubtitlesXmlRpc { int year = Integer.parseInt(matcher.group(2)); int imdbid = Integer.parseInt(movie.get("id")); - movies.add(new MovieDescriptor(name, year, imdbid)); + movies.add(new Movie(name, year, imdbid)); } else { Logger.getLogger(OpenSubtitlesXmlRpc.class.getName()).log(Level.WARNING, "Error parsing title: " + movie); } @@ -218,11 +218,11 @@ public class OpenSubtitlesXmlRpc { @SuppressWarnings("unchecked") - public Map checkMovieHash(Collection hashes) throws XmlRpcFault { + public Map checkMovieHash(Collection hashes) throws XmlRpcFault { Map response = invoke("CheckMovieHash", token, hashes); Map movieHashData = (Map) response.get("data"); - Map movieHashMap = new HashMap(); + Map movieHashMap = new HashMap(); for (Entry entry : movieHashData.entrySet()) { // empty associative arrays are deserialized as array, not as map @@ -234,7 +234,7 @@ public class OpenSubtitlesXmlRpc { int year = Integer.parseInt(info.get("MovieYear")); int imdb = Integer.parseInt(info.get("MovieImdbID")); - movieHashMap.put(hash, new MovieDescriptor(name, year, imdb)); + movieHashMap.put(hash, new Movie(name, year, imdb)); } } @@ -248,7 +248,7 @@ public class OpenSubtitlesXmlRpc { @SuppressWarnings("unchecked") - public MovieDescriptor getIMDBMovieDetails(int imdbid) throws XmlRpcFault { + public Movie getIMDBMovieDetails(int imdbid) throws XmlRpcFault { Map response = invoke("GetIMDBMovieDetails", token, imdbid); try { @@ -257,7 +257,7 @@ public class OpenSubtitlesXmlRpc { String name = data.get("title"); int year = Integer.parseInt(data.get("year")); - return new MovieDescriptor(name, year, imdbid); + return new Movie(name, year, imdbid); } catch (RuntimeException e) { // ignore, invalid response } diff --git a/source/net/sourceforge/filebot/web/SublightSubtitleClient.java b/source/net/sourceforge/filebot/web/SublightSubtitleClient.java index 9bbced2d..03dd6a99 100644 --- a/source/net/sourceforge/filebot/web/SublightSubtitleClient.java +++ b/source/net/sourceforge/filebot/web/SublightSubtitleClient.java @@ -99,7 +99,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit // remove classifier (e.g. tt0436992 -> 0436992) int id = Integer.parseInt(imdb.getId().substring(2)); - results.add(new MovieDescriptor(imdb.getTitle(), imdb.getYear(), id)); + results.add(new Movie(imdb.getTitle(), imdb.getYear(), id)); } } @@ -109,7 +109,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit @Override public List getSubtitleList(SearchResult searchResult, String languageName) throws WebServiceException { - MovieDescriptor movie = (MovieDescriptor) searchResult; + Movie movie = (Movie) searchResult; List subtitles = new ArrayList(); diff --git a/source/net/sourceforge/filebot/web/TMDbClient.java b/source/net/sourceforge/filebot/web/TMDbClient.java index 97eeae66..617f4f66 100644 --- a/source/net/sourceforge/filebot/web/TMDbClient.java +++ b/source/net/sourceforge/filebot/web/TMDbClient.java @@ -51,7 +51,7 @@ public class TMDbClient implements MovieIdentificationService { @Override - public List searchMovie(String query, Locale locale) throws IOException { + public List searchMovie(String query, Locale locale) throws IOException { try { return getMovies("Movie.search", query, locale); } catch (SAXException e) { @@ -62,18 +62,18 @@ public class TMDbClient implements MovieIdentificationService { } - public List searchMovie(File file, Locale locale) throws IOException, SAXException { + public List searchMovie(File file, Locale locale) throws IOException, SAXException { return searchMovie(OpenSubtitlesHasher.computeHash(file), file.length(), locale); } - public List searchMovie(String hash, long bytesize, Locale locale) throws IOException, SAXException { + public List searchMovie(String hash, long bytesize, Locale locale) throws IOException, SAXException { return getMovies("Media.getInfo", hash + "/" + bytesize, locale); } @Override - public MovieDescriptor getMovieDescriptor(int imdbid, Locale locale) throws Exception { + public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception { URL resource = getResource("Movie.imdbLookup", String.format("tt%07d", imdbid), locale); Node movie = selectNode("//movie", getDocument(resource)); @@ -83,16 +83,16 @@ public class TMDbClient implements MovieIdentificationService { String name = getTextContent("name", movie); int year = new Scanner(getTextContent("released", movie)).useDelimiter("\\D+").nextInt(); - return new MovieDescriptor(name, year, imdbid); + return new Movie(name, year, imdbid); } @Override - public MovieDescriptor[] getMovieDescriptors(File[] movieFiles, Locale locale) throws Exception { - MovieDescriptor[] movies = new MovieDescriptor[movieFiles.length]; + public Movie[] getMovieDescriptors(File[] movieFiles, Locale locale) throws Exception { + Movie[] movies = new Movie[movieFiles.length]; for (int i = 0; i < movies.length; i++) { - List options = searchMovie(movieFiles[i], locale); + List options = searchMovie(movieFiles[i], locale); // just use first result, if possible movies[i] = options.isEmpty() ? null : options.get(0); @@ -102,8 +102,8 @@ public class TMDbClient implements MovieIdentificationService { } - protected List getMovies(String method, String parameter, Locale locale) throws IOException, SAXException { - List result = new ArrayList(); + protected List getMovies(String method, String parameter, Locale locale) throws IOException, SAXException { + List result = new ArrayList(); for (Node node : selectNodes("//movie", getDocument(getResource(method, parameter, locale)))) { try { @@ -115,7 +115,7 @@ public class TMDbClient implements MovieIdentificationService { // imdb id will be tt1234567, but we only care about the number int imdbid = new Scanner(getTextContent("imdb_id", node)).useDelimiter("\\D+").nextInt(); - result.add(new MovieDescriptor(name, year, imdbid)); + result.add(new Movie(name, year, imdbid)); } catch (RuntimeException e) { // release date or imdb id are undefined } diff --git a/test/net/sourceforge/filebot/web/IMDbClientTest.java b/test/net/sourceforge/filebot/web/IMDbClientTest.java index ce6e9b6d..2ddfa80c 100644 --- a/test/net/sourceforge/filebot/web/IMDbClientTest.java +++ b/test/net/sourceforge/filebot/web/IMDbClientTest.java @@ -18,7 +18,7 @@ public class IMDbClientTest { public void search() throws Exception { List results = imdb.search("battlestar"); - MovieDescriptor movie = (MovieDescriptor) results.get(0); + Movie movie = (Movie) results.get(0); assertEquals("Battlestar Galactica", movie.getName()); assertEquals(2004, movie.getYear()); @@ -32,7 +32,7 @@ public class IMDbClientTest { public void searchMiniSeries() throws Exception { List results = imdb.search("generation kill"); - MovieDescriptor movie = (MovieDescriptor) results.get(0); + Movie movie = (Movie) results.get(0); assertEquals("Generation Kill", movie.getName()); assertEquals(2008, movie.getYear()); @@ -55,7 +55,7 @@ public class IMDbClientTest { // exactly one search result assertEquals(1, results.size(), 0); - MovieDescriptor movie = (MovieDescriptor) results.get(0); + Movie movie = (Movie) results.get(0); assertEquals("My Name Is Earl", movie.getName()); assertEquals(460091, movie.getImdbId(), 0); @@ -64,7 +64,7 @@ public class IMDbClientTest { @Test public void getEpisodeList() throws Exception { - List list = imdb.getEpisodeList(new MovieDescriptor("Buffy", 1997, 118276)); + List list = imdb.getEpisodeList(new Movie("Buffy", 1997, 118276)); assertEquals(145, list.size()); @@ -88,7 +88,7 @@ public class IMDbClientTest { @Test public void getEpisodeListWithUnknownSeason() throws Exception { - List list = imdb.getEpisodeList(new MovieDescriptor("Mushishi", 2005, 807832)); + List list = imdb.getEpisodeList(new Movie("Mushishi", 2005, 807832)); assertEquals(26, list.size()); @@ -103,7 +103,7 @@ public class IMDbClientTest { @Test public void getEpisodeListLink() throws Exception { - assertEquals("http://www.imdb.com/title/tt0407362/episodes", imdb.getEpisodeListLink(new MovieDescriptor("Battlestar Galactica", 2004, 407362)).toString()); + assertEquals("http://www.imdb.com/title/tt0407362/episodes", imdb.getEpisodeListLink(new Movie("Battlestar Galactica", 2004, 407362)).toString()); } } diff --git a/test/net/sourceforge/filebot/web/OpenSubtitlesXmlRpcTest.java b/test/net/sourceforge/filebot/web/OpenSubtitlesXmlRpcTest.java index eafb537a..3acaa037 100644 --- a/test/net/sourceforge/filebot/web/OpenSubtitlesXmlRpcTest.java +++ b/test/net/sourceforge/filebot/web/OpenSubtitlesXmlRpcTest.java @@ -34,8 +34,8 @@ public class OpenSubtitlesXmlRpcTest { @Test public void search() throws Exception { - List list = xmlrpc.searchMoviesOnIMDB("babylon 5"); - MovieDescriptor sample = (MovieDescriptor) list.get(0); + List list = xmlrpc.searchMoviesOnIMDB("babylon 5"); + Movie sample = (Movie) list.get(0); // check sample entry assertEquals("\"Babylon 5\"", sample.getName()); @@ -122,8 +122,8 @@ public class OpenSubtitlesXmlRpcTest { @Test public void checkMovieHash() throws Exception { - Map results = xmlrpc.checkMovieHash(singleton("d7aa0275cace4410")); - MovieDescriptor movie = results.get("d7aa0275cace4410"); + Map results = xmlrpc.checkMovieHash(singleton("d7aa0275cace4410")); + Movie movie = results.get("d7aa0275cace4410"); assertEquals("Iron Man", movie.getName()); assertEquals(2008, movie.getYear()); @@ -133,7 +133,7 @@ public class OpenSubtitlesXmlRpcTest { @Test public void checkMovieHashInvalid() throws Exception { - Map results = xmlrpc.checkMovieHash(singleton("0123456789abcdef")); + Map results = xmlrpc.checkMovieHash(singleton("0123456789abcdef")); // no movie info assertTrue(results.isEmpty()); @@ -142,7 +142,7 @@ public class OpenSubtitlesXmlRpcTest { @Test public void getIMDBMovieDetails() throws Exception { - MovieDescriptor movie = xmlrpc.getIMDBMovieDetails(371746); + Movie movie = xmlrpc.getIMDBMovieDetails(371746); assertEquals("Iron Man", movie.getName()); assertEquals(2008, movie.getYear()); @@ -152,7 +152,7 @@ public class OpenSubtitlesXmlRpcTest { @Test public void getIMDBMovieDetailsInvalid() throws Exception { - MovieDescriptor movie = xmlrpc.getIMDBMovieDetails(371746); + Movie movie = xmlrpc.getIMDBMovieDetails(371746); assertEquals("Iron Man", movie.getName()); assertEquals(2008, movie.getYear()); diff --git a/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java b/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java index 911ac75a..cda97bd5 100644 --- a/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java +++ b/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java @@ -33,7 +33,7 @@ public class SublightSubtitleClientTest { public void search() { List list = client.search("babylon 5"); - MovieDescriptor sample = (MovieDescriptor) list.get(0); + Movie sample = (Movie) list.get(0); // check sample entry assertEquals("Babylon 5", sample.getName()); @@ -46,7 +46,7 @@ public class SublightSubtitleClientTest { @Test public void getSubtitleListEnglish() { - List list = client.getSubtitleList(new MovieDescriptor("Heroes", 2006, 813715), "English"); + List list = client.getSubtitleList(new Movie("Heroes", 2006, 813715), "English"); SubtitleDescriptor sample = list.get(0); @@ -60,7 +60,7 @@ public class SublightSubtitleClientTest { @Test public void getSubtitleListAllLanguages() { - List list = client.getSubtitleList(new MovieDescriptor("Terminator 2", 1991, 103064), null); + List list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), null); SubtitleDescriptor sample = list.get(0); diff --git a/test/net/sourceforge/filebot/web/TMDbClientTest.java b/test/net/sourceforge/filebot/web/TMDbClientTest.java index 76cc7fc3..cd86a6fe 100644 --- a/test/net/sourceforge/filebot/web/TMDbClientTest.java +++ b/test/net/sourceforge/filebot/web/TMDbClientTest.java @@ -18,8 +18,8 @@ public class TMDbClientTest { @Test public void searchByName() throws Exception { - List result = tmdb.searchMovie("Serenity", Locale.CHINESE); - MovieDescriptor movie = result.get(0); + List result = tmdb.searchMovie("Serenity", Locale.CHINESE); + Movie movie = result.get(0); assertEquals("冲出宁静号", movie.getName()); assertEquals(2005, movie.getYear()); @@ -29,8 +29,8 @@ public class TMDbClientTest { @Test public void searchByHash() throws Exception { - List results = tmdb.searchMovie("907172e7fe51ba57", 742086656, Locale.ENGLISH); - MovieDescriptor movie = results.get(0); + List results = tmdb.searchMovie("907172e7fe51ba57", 742086656, Locale.ENGLISH); + Movie movie = results.get(0); assertEquals("Sin City", movie.getName()); assertEquals(2005, movie.getYear()); @@ -40,7 +40,7 @@ public class TMDbClientTest { @Test public void searchByIMDB() throws Exception { - MovieDescriptor movie = tmdb.getMovieDescriptor(418279, Locale.ENGLISH); + Movie movie = tmdb.getMovieDescriptor(418279, Locale.ENGLISH); assertEquals("Transformers", movie.getName()); assertEquals(2007, movie.getYear());