From 50be406bbf448d93a2c669419b494797cdde675e Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 14 Jun 2023 22:04:31 +0200 Subject: show series as poster --- tools/src/tmdb.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'tools/src/tmdb.rs') diff --git a/tools/src/tmdb.rs b/tools/src/tmdb.rs index 6f8c341..5f21afd 100644 --- a/tools/src/tmdb.rs +++ b/tools/src/tmdb.rs @@ -21,14 +21,14 @@ pub struct TmdbQueryResult { pub backdrop_path: Option, pub genre_ids: Vec, pub id: u64, - pub original_language: String, - pub original_title: String, + pub original_language: Option, + pub original_title: Option, pub overview: String, pub popularity: f64, pub poster_path: Option, - pub release_date: String, - pub title: String, - pub video: bool, + pub release_date: Option, + pub title: Option, + pub name: Option, pub vote_average: f64, pub vote_count: usize, } @@ -39,21 +39,21 @@ pub struct TmdbDetails { pub backdrop_path: Option, pub genres: Vec, pub id: u64, - pub original_language: String, - pub original_title: String, + pub original_language: Option, + pub original_title: Option, pub overview: String, pub popularity: f64, pub poster_path: Option, - pub release_date: String, - pub title: String, - pub video: bool, + pub release_date: Option, + pub title: Option, + pub name: Option, pub vote_average: f64, pub vote_count: usize, - pub budget: usize, + pub budget: Option, pub homepage: Option, pub imdb_id: Option, pub production_companies: Vec, - pub revenue: usize, + pub revenue: Option, pub tagline: Option, } @@ -70,19 +70,19 @@ pub struct TmdbProductionCompany { pub logo_path: Option, } -pub fn tmdb_search(query: &str, key: &str) -> anyhow::Result { +pub fn tmdb_search(kind: &str, query: &str, key: &str) -> anyhow::Result { info!("searching tmdb: {query:?}"); Ok(reqwest::blocking::get(&format!( - "https://api.themoviedb.org/3/search/movie?query={}&api_key={key}", + "https://api.themoviedb.org/3/search/{kind}?query={}&api_key={key}", query.replace(" ", "+") ))? .json::()?) } -pub fn tmdb_details(id: u64, key: &str) -> anyhow::Result { +pub fn tmdb_details(kind: &str, id: u64, key: &str) -> anyhow::Result { info!("fetching details: {id:?}"); Ok(reqwest::blocking::get(&format!( - "https://api.themoviedb.org/3/movie/{id}?api_key={key}" + "https://api.themoviedb.org/3/{kind}/{id}?api_key={key}" ))? .json()?) } -- cgit v1.2.3-70-g09d2