1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 16:28:51 -05:00

* simplify classname

This commit is contained in:
Reinhard Pointner 2011-09-22 12:55:04 +00:00
parent ba622eafd1
commit bafb33d676
18 changed files with 94 additions and 93 deletions

View File

@ -2,7 +2,7 @@
application.name: FileBot
application.version: 2.0
# google analytics
# google analytics
analytics.WebPropertyID: UA-25379256-2
# database api keys

View File

@ -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<SearchResult>(db.searchMovie(query, locale)), strict);
movieDescriptors[0] = (Movie) selectSearchResult(query, new ArrayList<SearchResult>(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();

View File

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

View File

@ -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<MovieDescriptor, SortedSet<File>> filesByMovie = new HashMap<MovieDescriptor, SortedSet<File>>();
Map<Movie, SortedSet<File>> filesByMovie = new HashMap<Movie, SortedSet<File>>();
// 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<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
for (Entry<MovieDescriptor, SortedSet<File>> entry : filesByMovie.entrySet()) {
MovieDescriptor movie = entry.getKey();
for (Entry<Movie, SortedSet<File>> 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, MovieDescriptor>(file, part));
matches.add(new Match<File, Movie>(file, part));
}
}
@ -163,11 +163,11 @@ class MovieHashMatcher implements AutoCompleteMatcher {
}
protected MovieDescriptor grabMovieName(File movieFile, Locale locale, boolean autodetect, MovieDescriptor... suggestions) throws Exception {
List<MovieDescriptor> options = new ArrayList<MovieDescriptor>();
protected Movie grabMovieName(File movieFile, Locale locale, boolean autodetect, Movie... suggestions) throws Exception {
List<Movie> options = new ArrayList<Movie>();
// 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<MovieDescriptor> options) throws Exception {
protected Movie selectMovie(final List<Movie> options) throws Exception {
if (options.size() == 1) {
return options.get(0);
}
// show selection dialog on EDT
final RunnableFuture<MovieDescriptor> showSelectDialog = new FutureTask<MovieDescriptor>(new Callable<MovieDescriptor>() {
final RunnableFuture<Movie> showSelectDialog = new FutureTask<Movie>(new Callable<Movie>() {
@Override
public MovieDescriptor call() throws Exception {
public Movie call() throws Exception {
// multiple results have been found, user must select one
SelectDialog<MovieDescriptor> selectDialog = new SelectDialog<MovieDescriptor>(null, options);
SelectDialog<Movie> selectDialog = new SelectDialog<Movie>(null, options);
selectDialog.getHeaderLabel().setText("Select Movie:");
selectDialog.getCancelAction().putValue(Action.NAME, "Ignore");

View File

@ -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<Class>(types)) {
Analytics.trackEvent("GUI", "Rename", it.getSimpleName(), frequency(types, it));
Analytics.trackEvent(getApplicationName(), "Rename", it.getSimpleName(), frequency(types, it));
}
}
}

View File

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

View File

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

View File

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

View File

@ -17,12 +17,12 @@ public interface MovieIdentificationService {
public Icon getIcon();
public List<MovieDescriptor> searchMovie(String query, Locale locale) throws Exception;
public List<Movie> 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;
}

View File

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

View File

@ -73,7 +73,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
@Override
public List<SubtitleDescriptor> 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<MovieDescriptor> searchMovie(String query, Locale locale) throws Exception {
public List<Movie> 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<String, Integer> indexMap = new HashMap<String, Integer>(movieFiles.length);
@ -182,7 +182,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
login();
// dispatch single query for all hashes
for (Entry<String, MovieDescriptor> entry : xmlrpc.checkMovieHash(indexMap.keySet()).entrySet()) {
for (Entry<String, Movie> 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) {

View File

@ -121,11 +121,11 @@ public class OpenSubtitlesXmlRpc {
@SuppressWarnings("unchecked")
public List<MovieDescriptor> searchMoviesOnIMDB(String query) throws XmlRpcFault {
public List<Movie> searchMoviesOnIMDB(String query) throws XmlRpcFault {
Map<?, ?> response = invoke("SearchMoviesOnIMDB", token, query);
List<Map<String, String>> movieData = (List<Map<String, String>>) response.get("data");
List<MovieDescriptor> movies = new ArrayList<MovieDescriptor>();
List<Movie> movies = new ArrayList<Movie>();
// 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<String, MovieDescriptor> checkMovieHash(Collection<String> hashes) throws XmlRpcFault {
public Map<String, Movie> checkMovieHash(Collection<String> hashes) throws XmlRpcFault {
Map<?, ?> response = invoke("CheckMovieHash", token, hashes);
Map<String, ?> movieHashData = (Map<String, ?>) response.get("data");
Map<String, MovieDescriptor> movieHashMap = new HashMap<String, MovieDescriptor>();
Map<String, Movie> movieHashMap = new HashMap<String, Movie>();
for (Entry<String, ?> 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
}

View File

@ -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<SubtitleDescriptor> getSubtitleList(SearchResult searchResult, String languageName) throws WebServiceException {
MovieDescriptor movie = (MovieDescriptor) searchResult;
Movie movie = (Movie) searchResult;
List<SubtitleDescriptor> subtitles = new ArrayList<SubtitleDescriptor>();

View File

@ -51,7 +51,7 @@ public class TMDbClient implements MovieIdentificationService {
@Override
public List<MovieDescriptor> searchMovie(String query, Locale locale) throws IOException {
public List<Movie> 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<MovieDescriptor> searchMovie(File file, Locale locale) throws IOException, SAXException {
public List<Movie> searchMovie(File file, Locale locale) throws IOException, SAXException {
return searchMovie(OpenSubtitlesHasher.computeHash(file), file.length(), locale);
}
public List<MovieDescriptor> searchMovie(String hash, long bytesize, Locale locale) throws IOException, SAXException {
public List<Movie> 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<MovieDescriptor> options = searchMovie(movieFiles[i], locale);
List<Movie> 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<MovieDescriptor> getMovies(String method, String parameter, Locale locale) throws IOException, SAXException {
List<MovieDescriptor> result = new ArrayList<MovieDescriptor>();
protected List<Movie> getMovies(String method, String parameter, Locale locale) throws IOException, SAXException {
List<Movie> result = new ArrayList<Movie>();
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
}

View File

@ -18,7 +18,7 @@ public class IMDbClientTest {
public void search() throws Exception {
List<SearchResult> 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<SearchResult> 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<Episode> list = imdb.getEpisodeList(new MovieDescriptor("Buffy", 1997, 118276));
List<Episode> 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<Episode> list = imdb.getEpisodeList(new MovieDescriptor("Mushishi", 2005, 807832));
List<Episode> 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());
}
}

View File

@ -34,8 +34,8 @@ public class OpenSubtitlesXmlRpcTest {
@Test
public void search() throws Exception {
List<MovieDescriptor> list = xmlrpc.searchMoviesOnIMDB("babylon 5");
MovieDescriptor sample = (MovieDescriptor) list.get(0);
List<Movie> 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<String, MovieDescriptor> results = xmlrpc.checkMovieHash(singleton("d7aa0275cace4410"));
MovieDescriptor movie = results.get("d7aa0275cace4410");
Map<String, Movie> 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<String, MovieDescriptor> results = xmlrpc.checkMovieHash(singleton("0123456789abcdef"));
Map<String, Movie> 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());

View File

@ -33,7 +33,7 @@ public class SublightSubtitleClientTest {
public void search() {
List<SearchResult> 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<SubtitleDescriptor> list = client.getSubtitleList(new MovieDescriptor("Heroes", 2006, 813715), "English");
List<SubtitleDescriptor> 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<SubtitleDescriptor> list = client.getSubtitleList(new MovieDescriptor("Terminator 2", 1991, 103064), null);
List<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), null);
SubtitleDescriptor sample = list.get(0);

View File

@ -18,8 +18,8 @@ public class TMDbClientTest {
@Test
public void searchByName() throws Exception {
List<MovieDescriptor> result = tmdb.searchMovie("Serenity", Locale.CHINESE);
MovieDescriptor movie = result.get(0);
List<Movie> 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<MovieDescriptor> results = tmdb.searchMovie("907172e7fe51ba57", 742086656, Locale.ENGLISH);
MovieDescriptor movie = results.get(0);
List<Movie> 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());