mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
Add convenience API
This commit is contained in:
parent
d218fbed99
commit
60519a43d6
@ -98,11 +98,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor
|
||||
}
|
||||
}
|
||||
|
||||
protected String[] languages() throws Exception {
|
||||
Object response = requestJson("languages", Locale.ROOT, Cache.ONE_MONTH);
|
||||
return streamJsonObjects(response, "data").map(it -> getString(it, "abbreviation")).toArray(String[]::new);
|
||||
}
|
||||
|
||||
protected List<SearchResult> search(String path, Map<String, Object> query, Locale locale, Duration expirationTime) throws Exception {
|
||||
Object json = requestJson(path + "?" + encodeParameters(query, true), locale, expirationTime);
|
||||
|
||||
@ -244,7 +239,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor
|
||||
|
||||
@Override
|
||||
public List<Artwork> getArtwork(int id, String category, Locale locale) throws Exception {
|
||||
Object json = requestJson("series/" + id + "/images/query?keyType=" + category, locale, Cache.ONE_WEEK);
|
||||
Object json = requestJson("series/" + id + "/images/query?keyType=" + category, locale, Cache.ONE_MONTH);
|
||||
|
||||
return streamJsonObjects(json, "data").map(it -> {
|
||||
try {
|
||||
@ -270,8 +265,18 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor
|
||||
try {
|
||||
return new URL("http://thetvdb.com/banners/" + path);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(Objects.toString(path));
|
||||
throw new IllegalArgumentException(path);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getLanguages() throws Exception {
|
||||
Object response = requestJson("languages", Locale.ROOT, Cache.ONE_MONTH);
|
||||
return streamJsonObjects(response, "data").map(it -> getString(it, "abbreviation")).collect(toList());
|
||||
}
|
||||
|
||||
public List<Map<?, ?>> getActors(int id, Locale locale) throws Exception {
|
||||
Object response = requestJson("series/" + id + "/actors", locale, Cache.ONE_MONTH);
|
||||
return streamJsonObjects(response, "data").map(it -> asMap(it)).collect(toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.filebot.web;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,12 +15,6 @@ public class TheTVDBClientTest {
|
||||
SearchResult wonderfalls = new SearchResult(78845, "Wonderfalls");
|
||||
SearchResult firefly = new SearchResult(78874, "Firefly");
|
||||
|
||||
@Test
|
||||
public void languages() throws Exception {
|
||||
String[] languages = thetvdb.languages();
|
||||
assertEquals("[zh, en, sv, no, da, fi, nl, de, it, es, fr, pl, hu, el, tr, ru, he, ja, pt, cs, sl, hr, ko]", asList(languages).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void search() throws Exception {
|
||||
// test default language and query escaping (blanks)
|
||||
@ -150,4 +143,10 @@ public class TheTVDBClientTest {
|
||||
assertEquals(8.0, i.getRating(), 1.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLanguages() throws Exception {
|
||||
List<String> languages = thetvdb.getLanguages();
|
||||
assertEquals("[zh, en, sv, no, da, fi, nl, de, it, es, fr, pl, hu, el, tr, ru, he, ja, pt, cs, sl, hr, ko]", languages.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user