mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-04 18:38:02 -05:00
Add {ci} collection index binding
This commit is contained in:
parent
6acd4b62ec
commit
9496ce6f10
@ -710,7 +710,7 @@ public class MediaBindingBean {
|
|||||||
@Define("ci")
|
@Define("ci")
|
||||||
public Integer getCollectionIndex() throws Exception {
|
public Integer getCollectionIndex() throws Exception {
|
||||||
if (infoObject instanceof Movie && getMovie().getTmdbId() > 0)
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -285,17 +285,14 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
|
|||||||
return new MovieInfo(fields, alternativeTitles, genres, certifications, spokenLanguages, productionCountries, productionCompanies, cast, trailers);
|
return new MovieInfo(fields, alternativeTitles, genres, certifications, spokenLanguages, productionCountries, productionCompanies, cast, trailers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Movie> getCollection(Movie movie, Locale locale) throws Exception {
|
public List<Movie> getCollection(int id, Locale locale) throws Exception {
|
||||||
Object movieResponse = request("movie/" + movie.getTmdbId(), emptyMap(), locale);
|
Object movieResponse = request("movie/" + id, emptyMap(), locale);
|
||||||
Map<?, ?> collectionObject = getMap(movieResponse, "belongs_to_collection");
|
Map<?, ?> collectionObject = getMap(movieResponse, "belongs_to_collection");
|
||||||
Integer collectionId = getInteger(collectionObject, "id");
|
Integer collectionId = getInteger(collectionObject, "id");
|
||||||
Object collectionResponse = request("collection/" + collectionId, emptyMap(), locale);
|
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 -> {
|
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();
|
return new Movie(getString(it, "title"), null, matchInteger(getString(it, "release_date")), -1, getInteger(it, "id"), locale);
|
||||||
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);
|
|
||||||
}).collect(toList());
|
}).collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ public class TMDbClientTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCollection() throws Exception {
|
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());
|
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