TheMovieDB::discoverBestOfYear

This commit is contained in:
Reinhard Pointner 2016-07-20 15:30:26 +08:00
parent 55a5814dd6
commit be9d70150d
2 changed files with 25 additions and 1 deletions

View File

@ -323,7 +323,22 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
}
public List<Movie> discover(LocalDate startDate, LocalDate endDate, Locale locale) throws Exception {
Object json = request("discover/movie?primary_release_date.gte=" + startDate + "&primary_release_date.lte=" + endDate + "&sort_by=popularity.desc", emptyMap(), locale, REQUEST_LIMIT);
Map<String, Object> parameters = new LinkedHashMap<String, Object>(3);
parameters.put("primary_release_date.gte", startDate);
parameters.put("primary_release_date.lte", endDate);
parameters.put("sort_by", "popularity.desc");
return discover(parameters, locale);
}
public List<Movie> discover(int year, Locale locale) throws Exception {
Map<String, Object> parameters = new LinkedHashMap<String, Object>(2);
parameters.put("primary_release_year", year);
parameters.put("sort_by", "vote_count.desc");
return discover(parameters, locale);
}
public List<Movie> discover(Map<String, Object> parameters, Locale locale) throws Exception {
Object json = request("discover/movie", parameters, locale, REQUEST_LIMIT);
return streamJsonObjects(json, "results").map(it -> {
String title = getString(it, "title");

View File

@ -123,6 +123,15 @@ public class TMDbClientTest {
assertEquals(177572, m.getTmdbId());
}
@Test
public void discoverBestOfYear() throws Exception {
Movie m = db.discover(2015, Locale.ENGLISH).get(0);
assertEquals("Mad Max: Fury Road", m.getName());
assertEquals(2015, m.getYear());
assertEquals(76341, m.getTmdbId());
}
@Ignore
@Test
public void floodLimit() throws Exception {