From 42568332b5433c97813e8c291db0fc0d15867b76 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 24 Oct 2023 19:32:26 +0200 Subject: import -> jellytool --- import/src/tmdb.rs | 95 ------------------------------------------------------ 1 file changed, 95 deletions(-) delete mode 100644 import/src/tmdb.rs (limited to 'import/src/tmdb.rs') diff --git a/import/src/tmdb.rs b/import/src/tmdb.rs deleted file mode 100644 index 5f21afd..0000000 --- a/import/src/tmdb.rs +++ /dev/null @@ -1,95 +0,0 @@ -/* - This file is part of jellything (https://codeberg.org/metamuffin/jellything) - which is licensed under the GNU Affero General Public License (version 3); see /COPYING. - Copyright (C) 2023 metamuffin -*/ -use log::info; -use serde::Deserialize; -use std::io::Write; - -#[derive(Debug, Clone, Deserialize)] -pub struct TmdbQuery { - pub page: usize, - pub results: Vec, - pub total_pages: usize, - pub total_results: usize, -} - -#[derive(Debug, Clone, Deserialize)] -pub struct TmdbQueryResult { - pub adult: bool, - pub backdrop_path: Option, - pub genre_ids: Vec, - pub id: u64, - pub original_language: Option, - pub original_title: Option, - pub overview: String, - pub popularity: f64, - pub poster_path: Option, - pub release_date: Option, - pub title: Option, - pub name: Option, - pub vote_average: f64, - pub vote_count: usize, -} - -#[derive(Debug, Clone, Deserialize)] -pub struct TmdbDetails { - pub adult: bool, - pub backdrop_path: Option, - pub genres: Vec, - pub id: u64, - pub original_language: Option, - pub original_title: Option, - pub overview: String, - pub popularity: f64, - pub poster_path: Option, - pub release_date: Option, - pub title: Option, - pub name: Option, - pub vote_average: f64, - pub vote_count: usize, - pub budget: Option, - pub homepage: Option, - pub imdb_id: Option, - pub production_companies: Vec, - pub revenue: Option, - pub tagline: Option, -} - -#[derive(Debug, Clone, Deserialize)] -pub struct TmdbGenre { - pub id: u64, - pub name: String, -} - -#[derive(Debug, Clone, Deserialize)] -pub struct TmdbProductionCompany { - pub id: u64, - pub name: String, - pub logo_path: Option, -} - -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/{kind}?query={}&api_key={key}", - query.replace(" ", "+") - ))? - .json::()?) -} - -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/{kind}/{id}?api_key={key}" - ))? - .json()?) -} - -pub fn tmdb_image(path: &str, out: &mut impl Write) -> anyhow::Result<()> { - info!("downloading image {path:?}"); - let mut res = reqwest::blocking::get(&format!("https://image.tmdb.org/t/p/original{path}"))?; - res.copy_to(out)?; - Ok(()) -} -- cgit v1.2.3-70-g09d2