Skip to content

BeesBoxler/tmdb-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TMDb API Wrapper  Latest Version

Rust wrapper for communicating with The Movie Database API.

Currently uses tokio and reqwest, but that is likely to change. I don't see any reason this package won't work in WASM. I haven't tested it though.

Usage

use tmdb::Tmdb;

const TMDB_API_KEY: &'static str = "mysupersecretapikey";

#[tokio::main]
async fn main() {
    // tmdb uses Rust's async/await. You don't have to use tokio,
    // but you will need an async runtime.

    let tmdb = Tmdb::create(TMDB_API_KEY);

    // Let's get a film and print its cast
    if let Ok(little_women) = tmdb.movies.get_movie(331482).await {
        let tagline = &little_women.tagline.as_ref().unwrap();
        let title = &little_women.title;
        let year = &little_women.release_date;

        println!("{title} (released: {year}) - {tagline}");
        println!("--------------------------------");

        if let Ok(credits) = &little_women.get_credits(&tmdb).await {
            credits.cast.iter().for_each(|actor| {
                let actor_name = &actor.name;
                let character = &actor.character;
                println!("{actor_name} | {character}");
            })
        }
    };
}
Little Women (released: 2019-12-25) - Own your story
--------------------------------
Saoirse Ronan | Josephine 'Jo' March
Florence Pugh | Amy March
Emma Watson | Margaret 'Meg' March
Eliza Scanlen | Elizabeth 'Beth' March
...

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Rust API for TMDb

Resources

Stars

Watchers

Forks

Languages