aboutsummaryrefslogtreecommitdiff
path: root/import/src/tmdb.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-05 23:10:15 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-05 23:10:15 +0100
commitdf36a85b54fd427cc0914320d29aa4f005e5aff7 (patch)
tree0702e87d55fe1a7b4d6913a35759e343f9923389 /import/src/tmdb.rs
parentfea9d99cef52a8ba258f5c8a11af08ec3304613e (diff)
downloadjellything-df36a85b54fd427cc0914320d29aa4f005e5aff7.tar
jellything-df36a85b54fd427cc0914320d29aa4f005e5aff7.tar.bz2
jellything-df36a85b54fd427cc0914320d29aa4f005e5aff7.tar.zst
trakt episode details
Diffstat (limited to 'import/src/tmdb.rs')
-rw-r--r--import/src/tmdb.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/import/src/tmdb.rs b/import/src/tmdb.rs
index 678ce61..70e95ce 100644
--- a/import/src/tmdb.rs
+++ b/import/src/tmdb.rs
@@ -116,6 +116,26 @@ impl Tmdb {
})
.await
}
+
+ pub async fn episode_details(
+ &self,
+ series_id: u64,
+ season: usize,
+ episode: usize,
+ ) -> anyhow::Result<Arc<TmdbEpisode>> {
+ async_cache_memory(&["api-tmdb-episode-details", &format!("{series_id} {season} {episode}")], || async move {
+ info!("tmdb episode details {series_id} S={season} E={episode}");
+ Ok(self
+ .image_client
+ .get(&format!("https://api.themoviedb.org/3/tv/{series_id}/season/{season}/episode/{episode}?api_key={}", self.key))
+ .send()
+ .await?
+ .error_for_status()?
+ .json()
+ .await?)
+ })
+ .await
+ }
}
pub fn parse_release_date(d: &str) -> anyhow::Result<Option<i64>> {
@@ -143,6 +163,18 @@ pub fn parse_release_date(d: &str) -> anyhow::Result<Option<i64>> {
}
#[derive(Debug, Clone, Deserialize, Encode, Decode)]
+pub struct TmdbEpisode {
+ pub air_date: String,
+ pub overview: String,
+ pub name: String,
+ pub id: u64,
+ pub runtime: f64,
+ pub still_path: Option<String>,
+ pub vote_average: f64,
+ pub vote_count: usize,
+}
+
+#[derive(Debug, Clone, Deserialize, Encode, Decode)]
pub struct TmdbPersonImage {
pub id: u64,
pub profiles: Vec<TmdbPersonImageProfile>,