From 8ae2acbdfbbdbbc9f5b5dee23e7d5cfb9400505b Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 13 May 2016 00:10:12 +0800 Subject: [PATCH] Refactor Movie --- source/net/filebot/web/Movie.java | 9 ++++----- source/net/filebot/web/OMDbClient.java | 2 +- source/net/filebot/web/TMDbClient.java | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/source/net/filebot/web/Movie.java b/source/net/filebot/web/Movie.java index ceaadb9e..80a438bb 100644 --- a/source/net/filebot/web/Movie.java +++ b/source/net/filebot/web/Movie.java @@ -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(getEffectiveNamesWithoutYear()).removeAll(other.getEffectiveNamesWithoutYear()); + return year == other.year && name.equals(other.name); } return false; diff --git a/source/net/filebot/web/OMDbClient.java b/source/net/filebot/web/OMDbClient.java index 334a7e2d..e2d36ae7 100644 --- a/source/net/filebot/web/OMDbClient.java +++ b/source/net/filebot/web/OMDbClient.java @@ -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); } diff --git a/source/net/filebot/web/TMDbClient.java b/source/net/filebot/web/TMDbClient.java index 73a422bc..2016e091 100644 --- a/source/net/filebot/web/TMDbClient.java +++ b/source/net/filebot/web/TMDbClient.java @@ -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); } }