test_tmdb 0.0.2-alpha.2

  • Readme
  • Changelog
  • Installing
  • 31

tmdb #

A TheMoviedb.org (TMDB) library for Dart.

Features #

  • Access to all API methods
  • Support for both console (dart:io) and web (dart:html) applications
  • User authentication, either with a username and password (obtains new session ID) or with a previously obtained session ID
  • You need to provide your own API key

Documentation #

See the full documentation.

Usage #

First import the proper library for the platform.

If your code is running on the Dart VM (where you'd use dart:io) then:

import 'package:tmdb/io.dart';

If your code runs on the browser (where you'd use dart:html) then:

import 'package:tmdb/html.dart';

With the library imported you can just create a new instance (providing your API key) and access all of its methods.

For example, a simple console application to get the top rated movies would look like this:

// Import the proper library
import 'package:tmdb/io.dart';

main() async {
  // Create a new TMDBApi instance
  TMDBApi tmdb = new TMDBApi('YOUR_API_KEY_HERE');

  // Get the top rated movies
  Map topRated = await tmdb.movies.getTopRated();

  // Loop through the results and print the title, year, and rating
  topRated['results'].forEach((v) {
    var title = v['title'];
    var year = DateTime.parse(v['release_date']).year;
    var rating = v['vote_average'].toStringAsFixed(1);
    print("$title ($year) * $rating/10");

Authentication #

If you already have a valid session ID for the user, you can just feed it to the library and start using any method that requires authentication:

// Create instance
TMDBApi tmdb = new TMDBApi('YOUR_API_KEY_HERE');

// Set the session ID
tmdb.authentication.sessionId = 'SESSION_ID_HERE';

// Get the user's information
var info = await tmdb.account.getInfo();

If you don't have a session ID for the user you want to authenticate you can easily obtain one using the login method.

// Create instance
TMDBApi tmdb = new TMDBApi('YOUR_API_KEY_HERE');

// Log in with a username and password
await tmdb.authentication.login('USERNAME_HERE', 'PASSWORD_HERE');

// The session ID is now stored in tmdb.authentication.sessionId
// so you can start using any API method.

// Get the user's information
var info = await tmdb.account.getInfo();

IMPORTANT: You should only use the login method once for each user because the API will generate a new session ID every time you do so. Once you have obtained it you should save it somewhere safe and feed it to the library whenever you need to (which is usually right after calling new TMDBApi()).

Futures vs async/await #

The easiest way to call the API methods is using the async/await syntax provided by Dart, like on the examples above.

To use it you just need to add the async modifier to the function that will be calling the asynchronous methods from this library. Then, prefix the actual call with await.

printMovieInfo(id) async {
  var info = await tmdb.movies.getInfo(id);

Or even

printMovieInfo(id) async {
  print(await tmdb.movies.getInfo(id));

If for any reason you can't or don't want to use async/await, you can just use the Futures directly:

printMovieInfo(id) {
  tmdb.movies.getInfo(id).then((info) {

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Change Log #

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

Unreleased #

0.0.2-alpha.1 - 2015-12-18

Fixed #

  • CHANGELOG links.

Changed #

  • Bump version number. Again. Because I screwed up earlier.

0.0.1-alpha.3 - 2015-12-18

Changed #

  • Version format.

0.0.1-alpha2 - 2015-12-18

Fixed #

  • README formatting.

0.0.1-alpha1 - 2015-12-18 #

Added #

  • All API methods implemented but untested. Highly unstable.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  test_tmdb: ^0.0.2-alpha.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:test_tmdb/core.dart';
import 'package:test_tmdb/html.dart';
import 'package:test_tmdb/io.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.4

Health suggestions

Fix lib/core.dart. (-15.67 points)

Analysis of lib/core.dart reported 34 hints, including:

line 75 col 21: Use = to separate a named parameter from its default value.

line 75 col 56: Use = to separate a named parameter from its default value.

line 80 col 15: Unnecessary new keyword.

line 87 col 15: Unnecessary new keyword.

line 98 col 15: Unnecessary new keyword.

Fix lib/src/groups/movies.dart. (-9.08 points)

Analysis of lib/src/groups/movies.dart reported 19 hints, including:

line 23 col 22: Unnecessary new keyword.

line 37 col 22: Unnecessary new keyword.

line 54 col 22: Unnecessary new keyword.

line 69 col 22: Unnecessary new keyword.

line 90 col 22: Unnecessary new keyword.

Fix lib/src/groups/tv.dart. (-7.24 points)

Analysis of lib/src/groups/tv.dart reported 15 hints, including:

line 27 col 22: Unnecessary new keyword.

line 42 col 22: Unnecessary new keyword.

line 70 col 22: Unnecessary new keyword.

line 94 col 22: Unnecessary new keyword.

line 108 col 22: Unnecessary new keyword.

Fix additional 18 files with analysis or formatting issues. (-34.59 points)

Additional issues in the following files:

  • lib/src/groups/account.dart (8 hints)
  • lib/src/groups/authentication.dart (8 hints)
  • lib/src/groups/search.dart (8 hints)
  • lib/src/groups/people.dart (7 hints)
  • lib/src/groups/tvepisodes.dart (7 hints)
  • lib/src/groups/lists.dart (6 hints)
  • lib/src/groups/tvseasons.dart (6 hints)
  • lib/src/params.dart (4 hints)
  • lib/src/groups/genres.dart (3 hints)
  • lib/html.dart (2 hints)
  • lib/src/groups/collections.dart (2 hints)
  • lib/src/groups/companies.dart (2 hints)
  • lib/src/groups/discover.dart (2 hints)
  • lib/io.dart (1 hint)
  • lib/src/groups.dart (1 hint)
  • lib/src/groups/credits.dart (1 hint)
  • lib/src/groups/find.dart (1 hint)
  • lib/src/groups/keywords.dart (1 hint)

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (http).

Package is getting outdated. (-11.78 points)

The package was last published 58 weeks ago.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and test_tmdb.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.11.3+16 0.11.3+17 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6