mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 00:08:51 -05:00
Add {ci} collection index binding
This commit is contained in:
parent
a7c736d40b
commit
6acd4b62ec
@ -707,6 +707,14 @@ public class MediaBindingBean {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Define("ci")
|
||||
public Integer getCollectionIndex() throws Exception {
|
||||
if (infoObject instanceof Movie && getMovie().getTmdbId() > 0)
|
||||
return TheMovieDB.getCollection(getMovie(), Locale.US).indexOf(getMovie()) + 1;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Define("info")
|
||||
public synchronized AssociativeScriptObject getMetaInfo() {
|
||||
if (infoObject instanceof Movie)
|
||||
|
@ -2,4 +2,4 @@
|
||||
parameter.exclude: ^StreamKind|^UniqueID|^StreamOrder|^ID|Count$
|
||||
|
||||
# preview expressions (keys are tagged so they can be sorted alphabetically)
|
||||
expressions: n, y, s, e, sxe, s00e00, t, d, startdate, absolute, ny, es, sy, sc, di, dc, age, special, episode, series, primaryTitle, alias, movie, tmdbid, imdbid, pi, pn, lang, subt, plex, plex.name, kodi, kodi.name, az, type, anime, regular, music, album, artist, albumArtist, actors, director, collection, genre, genres, languages, runtime, certification, rating, votes, vc, ac, cf, vf, hpi, aco, af, channels, resolution, dim, width, height, bitdepth, hdr, bitrate, kbps, mbps, khz, ws, hd, source, tags, s3d, group, original, info, info.network, info.status, info.productionCompanies, info.productionCountries, info.certifications, info.certifications.AU, info.certifications.DE, omdb.rating, omdb.votes, localize.deu.n, localize.deu.t, localize.zho.n, localize.zho.t, order.airdate.sxe, order.dvd.sxe, fn, ext, mediaType, mediaPath, file, file.name, folder, folder.name, mediaTitle, audioLanguages, textLanguages, duration, seconds, minutes, hours, bytes, megabytes, gigabytes, crc32, media.title, media.collection, media.season, media.part, media.partID, media.genre, media.contentType, media.description, media.lyrics, video[0].codecID, video[0].frameRate, video[0].displayAspectRatioString, video[0].scanType, audio.language, audio[0].bitRateString, audio[0].language, text.language, text[0].language, text[0].codecInfo, camera, camera.maker, camera.model, location, location.country
|
||||
expressions: n, y, s, e, sxe, s00e00, t, d, startdate, absolute, ny, es, sy, sc, di, dc, age, special, episode, series, primaryTitle, alias, movie, tmdbid, imdbid, pi, pn, lang, subt, plex, plex.name, kodi, kodi.name, az, type, anime, regular, music, album, artist, albumArtist, actors, director, collection, ci, genre, genres, languages, runtime, certification, rating, votes, vc, ac, cf, vf, hpi, aco, af, channels, resolution, dim, width, height, bitdepth, hdr, bitrate, kbps, mbps, khz, ws, hd, source, tags, s3d, group, original, info, info.network, info.status, info.productionCompanies, info.productionCountries, info.certifications, info.certifications.AU, info.certifications.DE, omdb.rating, omdb.votes, localize.deu.n, localize.deu.t, localize.zho.n, localize.zho.t, order.airdate.sxe, order.dvd.sxe, fn, ext, mediaType, mediaPath, file, file.name, folder, folder.name, mediaTitle, audioLanguages, textLanguages, duration, seconds, minutes, hours, bytes, megabytes, gigabytes, crc32, media.title, media.collection, media.season, media.part, media.partID, media.genre, media.contentType, media.description, media.lyrics, video[0].codecID, video[0].frameRate, video[0].displayAspectRatioString, video[0].scanType, audio.language, audio[0].bitRateString, audio[0].language, text.language, text[0].language, text[0].codecInfo, camera, camera.maker, camera.model, location, location.country
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.filebot.web;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static java.util.Comparator.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static net.filebot.CachedResource.*;
|
||||
import static net.filebot.Logging.*;
|
||||
@ -284,6 +285,20 @@ 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);
|
||||
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);
|
||||
}).collect(toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Artwork> getArtwork(int id, String category, Locale locale) throws Exception {
|
||||
Object images = request("movie/" + id + "/images", emptyMap(), Locale.ROOT);
|
||||
|
@ -114,6 +114,13 @@ public class TMDbClientTest {
|
||||
assertEquals("[宁静号]", titles.get("HK").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCollection() throws Exception {
|
||||
List<Movie> collection = TheMovieDB.getCollection(new Movie(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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArtwork() throws Exception {
|
||||
Artwork a = TheMovieDB.getArtwork(16320, "backdrops", Locale.ROOT).get(0);
|
||||
|
Loading…
Reference in New Issue
Block a user