mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
Internal TheMovieDB API for retrieving Country/AlternativeTitle mappings
This commit is contained in:
parent
109a43c5d7
commit
e8266b14dc
@ -311,6 +311,11 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getAlternativeTitles(int id) throws Exception {
|
||||||
|
Object titles = request("movie/" + id + "/alternative_titles", emptyMap(), Locale.ROOT, REQUEST_LIMIT);
|
||||||
|
return streamJsonObjects(titles, "titles").collect(toMap(it -> getString(it, "iso_3166_1"), it -> getString(it, "title"), (a, b) -> a, LinkedHashMap::new));
|
||||||
|
}
|
||||||
|
|
||||||
protected Object request(String resource, Map<String, Object> parameters, Locale locale, final FloodLimit limit) throws Exception {
|
protected Object request(String resource, Map<String, Object> parameters, Locale locale, final FloodLimit limit) throws Exception {
|
||||||
// default parameters
|
// default parameters
|
||||||
String key = parameters.isEmpty() ? resource : resource + '?' + encodeParameters(parameters, true);
|
String key = parameters.isEmpty() ? resource : resource + '?' + encodeParameters(parameters, true);
|
||||||
|
@ -8,6 +8,7 @@ import java.time.Duration;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -86,6 +87,14 @@ public class TMDbClientTest {
|
|||||||
assertEquals("Michael Bay", movie.getDirector());
|
assertEquals("Michael Bay", movie.getDirector());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAlternativeTitles() throws Exception {
|
||||||
|
Map<String, String> titles = db.getAlternativeTitles(16320); // Serenity
|
||||||
|
|
||||||
|
assertEquals("衝出寧靜號", titles.get("TW"));
|
||||||
|
assertEquals("萤火虫", titles.get("CN"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getArtwork() throws Exception {
|
public void getArtwork() throws Exception {
|
||||||
Artwork a = db.getArtwork(16320, "backdrops", Locale.ROOT).get(0);
|
Artwork a = db.getArtwork(16320, "backdrops", Locale.ROOT).get(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user