* 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:
parent
87bc1f7b47
commit
f85d706dce
|
@ -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
|
||||||
|
|
|
@ -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,39 +12,45 @@ 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);
|
||||||
Movie movie = result.get(0);
|
Movie movie = result.get(0);
|
||||||
|
|
||||||
assertEquals("冲出宁静号", movie.getName());
|
assertEquals("冲出宁静号", movie.getName());
|
||||||
assertEquals(2005, movie.getYear());
|
assertEquals(2005, movie.getYear());
|
||||||
assertEquals(-1, movie.getImdbId());
|
assertEquals(-1, movie.getImdbId());
|
||||||
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 {
|
||||||
Movie movie = tmdb.getMovieDescriptor(418279, Locale.ENGLISH);
|
Movie movie = tmdb.getMovieDescriptor(418279, Locale.ENGLISH);
|
||||||
|
|
||||||
assertEquals("Transformers", movie.getName());
|
assertEquals("Transformers", movie.getName());
|
||||||
assertEquals(2007, movie.getYear(), 0);
|
assertEquals(2007, movie.getYear(), 0);
|
||||||
assertEquals(418279, movie.getImdbId(), 0);
|
assertEquals(418279, movie.getImdbId(), 0);
|
||||||
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);
|
||||||
|
|
||||||
assertEquals("Transformers", movie.getName());
|
assertEquals("Transformers", movie.getName());
|
||||||
assertEquals("2007-07-02", movie.getReleased().toString());
|
assertEquals("2007-07-02", movie.getReleased().toString());
|
||||||
assertEquals("PG-13", movie.getCertification());
|
assertEquals("PG-13", movie.getCertification());
|
||||||
|
@ -54,16 +59,14 @@ public class TMDbClientTest {
|
||||||
assertEquals("Michael Bay", movie.getDirector());
|
assertEquals("Michael Bay", movie.getDirector());
|
||||||
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");
|
||||||
assertEquals("backdrops", artwork.get(0).getCategory());
|
assertEquals("backdrops", artwork.get(0).getCategory());
|
||||||
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()) {
|
||||||
|
@ -71,5 +74,5 @@ public class TMDbClientTest {
|
||||||
assertEquals(16320, results.get(0).getTmdbId());
|
assertEquals(16320, results.get(0).getTmdbId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue