7 releases (stable)

Uses old Rust 2015

3.0.0 Feb 4, 2021
2.0.0 Apr 25, 2019
1.1.0 Apr 24, 2019
1.0.1 Dec 23, 2018
0.1.1 Apr 14, 2018

#198 in Video

Download history 5/week @ 2024-08-17 30/week @ 2024-08-24 16/week @ 2024-08-31 7/week @ 2024-09-07 27/week @ 2024-09-14 55/week @ 2024-09-21 44/week @ 2024-09-28 42/week @ 2024-10-05 2/week @ 2024-10-12 35/week @ 2024-10-19 37/week @ 2024-10-26 18/week @ 2024-11-02

98 downloads per month

MIT license

19KB
490 lines

The Movie Database

The Movie Database

This is a wrapper around the TMDb API.

Usage

extern crate tmdb;

use tmdb::model::*;
use tmdb::themoviedb::*;

fn main() {
    let tmdb = TMDb { api_key: env!("TMDB_API_KEY"), language: "en" };

    let movies = tmdb.search()
        .title("Interstellar")
        .year(2014)
        .execute()
        .unwrap();

    let id = movies.results[0].id;
    
    let interstellar: Movie = tmdb.fetch()
        .id(id)
        .execute()
        .unwrap();

    println!("{:#?}", interstellar);
}

Actions

Currently there are 3 actions available:

  • Searching
  • Fetching
  • Finding

Searching

You can search for movies by title and year.

let page = tmdb.search()
    .title("Bicentennial Man")
    .year(1999)
    .execute()
    .unwrap();

let movies = page.results;

Fetching

You can fetch a movie, when you know its ID. Then you get all the movie details.

let movie = tmdb.fetch()
    .id(157336)
    .execute()
    .unwrap();

When you don't have any movie ID, you can search for a movie and then easily fetch the full details.

let page = tmdb.search()
   .title("Bicentennial Man")
   .year(1999)
   .execute()
   .unwrap();

let movies = page.results;
let movie = movies[0].fetch(&tmdb).unwrap();

Furthermore you can request some more data with the append to response feature.

let movie = tmdb.fetch()
    .id(2277)
    .append_videos()
    .append_credits()
    .execute()
    .unwrap();

Finding

Finding a movie with an external ID is currently supported with IMDB IDs.

let find_result = tmdb.find()
    .imdb_id("tt0816692")
    .execute()
    .unwrap();

let movies = find_result.movie_results;

Acknowledgements

Dependencies

~22MB
~452K SLoC