mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-02 17:38:15 -05:00
Add {ci} collection index binding
This commit is contained in:
parent
6acd4b62ec
commit
9496ce6f10
source/net/filebot
test/net/filebot/web
@ -710,7 +710,7 @@ public class MediaBindingBean {
|
||||
@Define("ci")
|
||||
public Integer getCollectionIndex() throws Exception {
|
||||
if (infoObject instanceof Movie && getMovie().getTmdbId() > 0)
|
||||
return TheMovieDB.getCollection(getMovie(), Locale.US).indexOf(getMovie()) + 1;
|
||||
return TheMovieDB.getCollection(getMovie().getTmdbId(), Locale.US).indexOf(getMovie()) + 1;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -285,17 +285,14 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
|
||||
return new MovieInfo(fields, alternativeTitles, genres, certifications, spokenLanguages, productionCountries, productionCompanies, cast, trailers);
|
||||
}
|
||||
|
||||
public List<Movie> getCollection(Movie movie, Locale locale) throws Exception {
|
||||
Object movieResponse = request("movie/" + movie.getTmdbId(), emptyMap(), locale);
|
||||
public List<Movie> getCollection(int id, Locale locale) throws Exception {
|
||||
Object movieResponse = request("movie/" + id, emptyMap(), locale);
|
||||
Map<?, ?> collectionObject = getMap(movieResponse, "belongs_to_collection");
|
||||
Integer collectionId = getInteger(collectionObject, "id");
|
||||
Object collectionResponse = request("collection/" + collectionId, emptyMap(), locale);
|
||||
|
||||
return streamJsonObjects(collectionResponse, "parts").filter(it -> null != getString(it, "release_date")).sorted(comparing(it -> getString(it, "release_date"))).map(it -> {
|
||||
int id = getDouble(it, "id").intValue();
|
||||
int year = matchInteger(getString(it, "release_date")); // release date is often missing
|
||||
String title = getString(it, "title");
|
||||
return new Movie(title, null, year, -1, id, locale);
|
||||
return new Movie(getString(it, "title"), null, matchInteger(getString(it, "release_date")), -1, getInteger(it, "id"), locale);
|
||||
}).collect(toList());
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class TMDbClientTest {
|
||||
|
||||
@Test
|
||||
public void getCollection() throws Exception {
|
||||
List<Movie> collection = TheMovieDB.getCollection(new Movie(24253), Locale.ENGLISH); // Serenity
|
||||
List<Movie> collection = TheMovieDB.getCollection(24253, Locale.ENGLISH); // Serenity
|
||||
|
||||
assertEquals("[The Girl with the Dragon Tattoo (2009), The Girl Who Played with Fire (2009), The Girl Who Kicked the Hornet's Nest (2009)]", collection.toString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user