TMDb Client
This library allow to request content from The Movie Database API using async methods.
Download
To use the TMDbClient with Gradle:
compile 'com.github.rodrigobriet:tmdbclient:1.0.0'
with Maven:
<dependency>
<groupId>com.github.rodrigobriet</groupId>
<artifactId>tmdbclient</artifactId>
<version>1.0.0</version>
</dependency>
Usage
To use the API you need to create a new instance of the TMDb class giving you API key, a directory to be used as cache and the cache size in bytes.
File cacheFolder = new File("dir/for/cache/folder");
int cacheSizeInBytes = 1 * 1024 * 1024;
TMDb db = new TMDb("TMDB_APY_KEY", cacheFolder, cacheSizeInBytes);
The TMDb class has a method for each API endpoint category (getAccount(), getAuthentication(), getCertifications(), getChanges(), getCollections(), getCompanies(), getConfiguration(), getCredits(), getDiscover(), getFind(), getGenres(), getGuest(), getKeywords(), getLists(), getMovies(), getNetworks(), getPeople(), getReviews(), getSearch(), getTv(), getTvSeasons() and getTvEpisodes()
). This methods allow you to access the endpoints for each category.
How to request a resource
After you have a instance of TMDb, to request a endpoint you just need to get the category and get the resource.
int movieId = 550;
db.getMovies().getDetails(movieId).request(new RequestCallback<MoviesDetails>() {
@Override
public void onSucess(Header responseHeader, MoviesDetails model) {
}
@Override
public void onError(Header requestHeader, IOException e) {
}
@Override
public void OnFail(Header responseHeader, StatusMessage statusMessage) {
}
});
Each request need to receive a RequestCallback<?> implementation, where ? is the model type returned by te request.
Setting query strings
Some resources allow the use of a custom query string. To set this query you can use the setQuery()
method. Each resource allow a diferent type of query.
db.getMovies().getDetails(550)
.setQuery(MoviesDetailsQuery.LANGUAGE, "pt-BR")
.reque...
How to use append_to_response
The getPeople().getDetails()
, getMovies().getDetails
, getTv().getDetails
, getTvSeason().getDetails
and getTvEpisode().getDetails()
allow the use of a "special" query string called append_to_response. This query allow you to request extra information about the resource consuming only one request in the rate-limiting.
To set this query you can give extra attributes to the getDetails()
methods. Each resource has a set of appends values. For movies:
db.getMovies().getDetails(550, MoviesAppend.ACCOUNT_STATES, MoviesAppend.ALTERNATIVE_TITLES, MoviesAppend.CREDITS, MoviesAppend.EXTERNAL_IDS, MoviesAppend.IMAGES, MoviesAppend.KEYWORDS, MoviesAppend.LISTS, MoviesAppend.RECOMMENDATIONS, MoviesAppend.RELEASE_DATES, MoviesAppend.REVIEWS, MoviesAppend.SIMILAR, MoviesAppend.TRANSLATIONS, MoviesAppend.VIDEOS)
.setQuery(MoviesDetailsQuery.LANGUAGE, "pt-BR")
.reque...
Note
This library has NO affilitation with The Movie Database.