aboutsummaryrefslogtreecommitdiff
path: root/tools/src/tmdb.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-08-03 20:45:31 +0200
committermetamuffin <metamuffin@disroot.org>2023-08-03 20:45:31 +0200
commitd52233a7a304b7dadda383128eaa42aea02b3b74 (patch)
tree254ab9e7ca527b16afaa6fa1a7ad76fef220f9f6 /tools/src/tmdb.rs
parent5b71ccaf2bbe34f1d39d4f38f2b5c2090a9761b1 (diff)
downloadjellything-d52233a7a304b7dadda383128eaa42aea02b3b74.tar
jellything-d52233a7a304b7dadda383128eaa42aea02b3b74.tar.bz2
jellything-d52233a7a304b7dadda383128eaa42aea02b3b74.tar.zst
rename tools crate
Diffstat (limited to 'tools/src/tmdb.rs')
-rw-r--r--tools/src/tmdb.rs95
1 files changed, 0 insertions, 95 deletions
diff --git a/tools/src/tmdb.rs b/tools/src/tmdb.rs
deleted file mode 100644
index 5f21afd..0000000
--- a/tools/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 <metamuffin.org>
-*/
-use log::info;
-use serde::Deserialize;
-use std::io::Write;
-
-#[derive(Debug, Clone, Deserialize)]
-pub struct TmdbQuery {
- pub page: usize,
- pub results: Vec<TmdbQueryResult>,
- pub total_pages: usize,
- pub total_results: usize,
-}
-
-#[derive(Debug, Clone, Deserialize)]
-pub struct TmdbQueryResult {
- pub adult: bool,
- pub backdrop_path: Option<String>,
- pub genre_ids: Vec<u64>,
- pub id: u64,
- pub original_language: Option<String>,
- pub original_title: Option<String>,
- pub overview: String,
- pub popularity: f64,
- pub poster_path: Option<String>,
- pub release_date: Option<String>,
- pub title: Option<String>,
- pub name: Option<String>,
- pub vote_average: f64,
- pub vote_count: usize,
-}
-
-#[derive(Debug, Clone, Deserialize)]
-pub struct TmdbDetails {
- pub adult: bool,
- pub backdrop_path: Option<String>,
- pub genres: Vec<TmdbGenre>,
- pub id: u64,
- pub original_language: Option<String>,
- pub original_title: Option<String>,
- pub overview: String,
- pub popularity: f64,
- pub poster_path: Option<String>,
- pub release_date: Option<String>,
- pub title: Option<String>,
- pub name: Option<String>,
- pub vote_average: f64,
- pub vote_count: usize,
- pub budget: Option<usize>,
- pub homepage: Option<String>,
- pub imdb_id: Option<String>,
- pub production_companies: Vec<TmdbProductionCompany>,
- pub revenue: Option<usize>,
- pub tagline: Option<String>,
-}
-
-#[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<String>,
-}
-
-pub fn tmdb_search(kind: &str, query: &str, key: &str) -> anyhow::Result<TmdbQuery> {
- info!("searching tmdb: {query:?}");
- Ok(reqwest::blocking::get(&format!(
- "https://api.themoviedb.org/3/search/{kind}?query={}&api_key={key}",
- query.replace(" ", "+")
- ))?
- .json::<TmdbQuery>()?)
-}
-
-pub fn tmdb_details(kind: &str, id: u64, key: &str) -> anyhow::Result<TmdbDetails> {
- 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(())
-}