* fix tricky internal DB override TMDb response issue when using non-English language preferences

@see http://www.filebot.net/forums/viewtopic.php?f=6&t=1106&p=6797#p6797
This commit is contained in:
Reinhard Pointner 2013-11-18 14:41:19 +00:00
parent 87bc1f7b47
commit f85d706dce
2 changed files with 31 additions and 21 deletions

View File

@ -1,9 +1,10 @@
package net.sourceforge.filebot.web; package net.sourceforge.filebot.web;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
public class Movie extends SearchResult { public class Movie extends SearchResult {
@ -66,7 +67,13 @@ public class Movie extends SearchResult {
return tmdbId == other.tmdbId; return tmdbId == other.tmdbId;
} }
return year == other.year && name.equals(other.name); if (year != other.year) {
return false;
}
Set<String> intersection = new HashSet<String>(this.getEffectiveNames());
intersection.retainAll(other.getEffectiveNames());
return intersection.size() > 0;
} }
return false; return false;
@ -79,7 +86,7 @@ public class Movie extends SearchResult {
@Override @Override
public int hashCode() { public int hashCode() {
return Arrays.hashCode(new Object[] { name.toLowerCase(), year }); return year;
} }
@Override @Override

View File

@ -1,10 +1,9 @@
package net.sourceforge.filebot.web; package net.sourceforge.filebot.web;
import static net.sourceforge.filebot.Settings.*; import static net.sourceforge.filebot.Settings.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -13,12 +12,10 @@ import net.sourceforge.filebot.web.TMDbClient.MovieInfo;
import org.junit.Test; import org.junit.Test;
public class TMDbClientTest { public class TMDbClientTest {
private final TMDbClient tmdb = new TMDbClient(getApplicationProperty("themoviedb.apikey")); private final TMDbClient tmdb = new TMDbClient(getApplicationProperty("themoviedb.apikey"));
@Test @Test
public void searchByName() throws Exception { public void searchByName() throws Exception {
List<Movie> result = tmdb.searchMovie("Serenity", Locale.CHINESE); List<Movie> result = tmdb.searchMovie("Serenity", Locale.CHINESE);
@ -30,6 +27,15 @@ public class TMDbClientTest {
assertEquals(16320, movie.getTmdbId()); assertEquals(16320, movie.getTmdbId());
} }
@Test
public void searchByNameGermanResults() throws Exception {
List<Movie> result = tmdb.searchMovie("East of Eden", Locale.GERMAN);
Movie movie = result.get(0);
assertEquals("Jenseits von Eden", movie.getName());
assertEquals(1955, movie.getYear());
assertEquals(Arrays.asList("Jenseits von Eden (1955)", "East of Eden (1955)"), movie.getEffectiveNames());
}
@Test @Test
public void searchByIMDB() throws Exception { public void searchByIMDB() throws Exception {
@ -41,7 +47,6 @@ public class TMDbClientTest {
assertEquals(1858, movie.getTmdbId(), 0); assertEquals(1858, movie.getTmdbId(), 0);
} }
@Test @Test
public void getMovieInfo() throws Exception { public void getMovieInfo() throws Exception {
MovieInfo movie = tmdb.getMovieInfo(new Movie(null, 0, 418279, -1), Locale.ENGLISH); MovieInfo movie = tmdb.getMovieInfo(new Movie(null, 0, 418279, -1), Locale.ENGLISH);
@ -55,7 +60,6 @@ public class TMDbClientTest {
assertEquals("Editor", movie.getCast().get(30).getJob()); assertEquals("Editor", movie.getCast().get(30).getJob());
} }
@Test @Test
public void getArtwork() throws Exception { public void getArtwork() throws Exception {
List<Artwork> artwork = tmdb.getArtwork("tt0418279"); List<Artwork> artwork = tmdb.getArtwork("tt0418279");
@ -63,7 +67,6 @@ public class TMDbClientTest {
assertEquals("http://d3gtl9l2a4fn1j.cloudfront.net/t/p/original/jC4bQLEEcpM8N7BjpkMtP0zPakJ.jpg", artwork.get(0).getUrl().toString()); assertEquals("http://d3gtl9l2a4fn1j.cloudfront.net/t/p/original/jC4bQLEEcpM8N7BjpkMtP0zPakJ.jpg", artwork.get(0).getUrl().toString());
} }
@Test @Test
public void floodLimit() throws Exception { public void floodLimit() throws Exception {
for (Locale it : Locale.getAvailableLocales()) { for (Locale it : Locale.getAvailableLocales()) {