mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Movie extends SearchResult {
|
||||
|
||||
@ -66,7 +67,13 @@ public class Movie extends SearchResult {
|
||||
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;
|
||||
@ -79,7 +86,7 @@ public class Movie extends SearchResult {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(new Object[] { name.toLowerCase(), year });
|
||||
return year;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
import static net.sourceforge.filebot.Settings.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -13,39 +12,45 @@ import net.sourceforge.filebot.web.TMDbClient.MovieInfo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class TMDbClientTest {
|
||||
|
||||
|
||||
private final TMDbClient tmdb = new TMDbClient(getApplicationProperty("themoviedb.apikey"));
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void searchByName() throws Exception {
|
||||
List<Movie> result = tmdb.searchMovie("Serenity", Locale.CHINESE);
|
||||
Movie movie = result.get(0);
|
||||
|
||||
|
||||
assertEquals("冲出宁静号", movie.getName());
|
||||
assertEquals(2005, movie.getYear());
|
||||
assertEquals(-1, movie.getImdbId());
|
||||
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
|
||||
public void searchByIMDB() throws Exception {
|
||||
Movie movie = tmdb.getMovieDescriptor(418279, Locale.ENGLISH);
|
||||
|
||||
|
||||
assertEquals("Transformers", movie.getName());
|
||||
assertEquals(2007, movie.getYear(), 0);
|
||||
assertEquals(418279, movie.getImdbId(), 0);
|
||||
assertEquals(1858, movie.getTmdbId(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getMovieInfo() throws Exception {
|
||||
MovieInfo movie = tmdb.getMovieInfo(new Movie(null, 0, 418279, -1), Locale.ENGLISH);
|
||||
|
||||
|
||||
assertEquals("Transformers", movie.getName());
|
||||
assertEquals("2007-07-02", movie.getReleased().toString());
|
||||
assertEquals("PG-13", movie.getCertification());
|
||||
@ -54,16 +59,14 @@ public class TMDbClientTest {
|
||||
assertEquals("Michael Bay", movie.getDirector());
|
||||
assertEquals("Editor", movie.getCast().get(30).getJob());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getArtwork() throws Exception {
|
||||
List<Artwork> artwork = tmdb.getArtwork("tt0418279");
|
||||
assertEquals("backdrops", artwork.get(0).getCategory());
|
||||
assertEquals("http://d3gtl9l2a4fn1j.cloudfront.net/t/p/original/jC4bQLEEcpM8N7BjpkMtP0zPakJ.jpg", artwork.get(0).getUrl().toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void floodLimit() throws Exception {
|
||||
for (Locale it : Locale.getAvailableLocales()) {
|
||||
@ -71,5 +74,5 @@ public class TMDbClientTest {
|
||||
assertEquals(16320, results.get(0).getTmdbId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user