Refactor Movie

This commit is contained in:
Reinhard Pointner 2016-05-13 00:10:12 +08:00
parent 4827f212c7
commit 8ae2acbdfb
3 changed files with 6 additions and 7 deletions

View File

@ -2,7 +2,6 @@ package net.filebot.web;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@ -20,7 +19,7 @@ public class Movie extends SearchResult {
}
public Movie(int imdbId) {
this(null, 0, imdbId, -1);
this(null, 0, imdbId, 0);
}
public Movie(String name, int year, int imdbId, int tmdbId) {
@ -28,11 +27,11 @@ public class Movie extends SearchResult {
}
public Movie(String name, String[] aliasNames, int year, int imdbId, int tmdbId, Locale locale) {
super(tmdbId > 0 ? tmdbId : imdbId > 0 ? imdbId : -1, name, aliasNames);
super(tmdbId > 0 ? tmdbId : imdbId > 0 ? imdbId : 0, name, aliasNames);
this.year = year;
this.imdbId = imdbId;
this.tmdbId = tmdbId;
this.language = (locale == null ? null : locale.getLanguage());
this.language = locale == null ? null : locale.getLanguage();
}
public int getYear() {
@ -85,7 +84,7 @@ public class Movie extends SearchResult {
return imdbId == other.imdbId;
}
return year == other.year && new HashSet<String>(getEffectiveNamesWithoutYear()).removeAll(other.getEffectiveNamesWithoutYear());
return year == other.year && name.equals(other.name);
}
return false;

View File

@ -120,7 +120,7 @@ public class OMDbClient implements MovieIdentificationService {
if (name.length() <= 0 || year <= 1900 || imdbid <= 0)
throw new IllegalArgumentException();
return new Movie(name, year, imdbid, -1);
return new Movie(name, year, imdbid, 0);
} catch (Exception e) {
throw new IllegalArgumentException("Illegal fields: " + info);
}

View File

@ -148,7 +148,7 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
String[] aliasNames = info.getOriginalName() == null || info.getOriginalName().isEmpty() || info.getOriginalName().equals(name) ? new String[0] : new String[] { info.getOriginalName() };
int year = info.getReleased() != null ? info.getReleased().getYear() : id.getYear();
int tmdbid = info.getId();
int imdbid = info.getImdbId() != null ? info.getImdbId() : -1;
int imdbid = info.getImdbId() != null ? info.getImdbId() : 0;
return new Movie(name, aliasNames, year, imdbid, tmdbid, locale);
}
}