Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.github.rodrigobriet:tmdbclient

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.rodrigobriet:tmdbclient

A java library to request content from The Movie Database API (TMDb)

  • 1.0.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

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; // "1MB"
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) {
    // TODO Auto-generated method stub
  }

  @Override
  public void onError(Header requestHeader, IOException e) {
    // TODO Auto-generated method stub
  }

  @Override
  public void OnFail(Header responseHeader, StatusMessage statusMessage) {
    // TODO Auto-generated method stub
  }
});

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.

FAQs

Package last updated on 25 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc