You've already forked flix
Model updates, bugfixes, and a new muxing cli tool
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "flix-tmdb"
|
||||
version = "0.0.18"
|
||||
version = "0.0.19"
|
||||
license-file.workspace = true
|
||||
|
||||
description = "Clients and models for fetching data from TMDB"
|
||||
|
||||
@@ -3,8 +3,9 @@ use core::time::Duration;
|
||||
use flix_model::numbers::EpisodeNumber;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use url::Url;
|
||||
|
||||
use super::duration_from_minutes;
|
||||
use super::{duration_from_minutes, still_url_from_path};
|
||||
|
||||
/// A deserialized Episode from the TMDB API
|
||||
#[derive(Debug, Clone, serde::Deserialize)]
|
||||
@@ -18,7 +19,10 @@ pub struct Episode {
|
||||
pub overview: String,
|
||||
/// The episode's air date
|
||||
pub air_date: NaiveDate,
|
||||
/// The movie's runtime
|
||||
/// The episode's runtime
|
||||
#[serde(deserialize_with = "duration_from_minutes")]
|
||||
pub runtime: Duration,
|
||||
/// The episode's still path
|
||||
#[serde(deserialize_with = "still_url_from_path")]
|
||||
pub still_path: Option<Url>,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
//! Deserializable types from the TMDB API
|
||||
|
||||
use core::str::FromStr;
|
||||
use core::time::Duration;
|
||||
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use url::Url;
|
||||
|
||||
pub mod id;
|
||||
|
||||
@@ -22,6 +24,24 @@ fn duration_from_minutes<'de, D>(deserializer: D) -> Result<Duration, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let minutes = u64::deserialize(deserializer)?;
|
||||
let minutes = u64::deserialize(deserializer).unwrap_or(0);
|
||||
Ok(Duration::from_secs(minutes.saturating_mul(60)))
|
||||
}
|
||||
|
||||
fn still_url_from_path<'de, D>(deserializer: D) -> Result<Option<Url>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
const TMDB_IMAGE_BASE: &str = "http://image.tmdb.org/t/p/";
|
||||
const TMDB_IMAGE_QUALITY: &str = "original";
|
||||
|
||||
let path = Option::<&str>::deserialize(deserializer)?;
|
||||
|
||||
Ok(path.and_then(|path| {
|
||||
Url::from_str(&format!(
|
||||
"{}{}{}",
|
||||
TMDB_IMAGE_BASE, TMDB_IMAGE_QUALITY, path
|
||||
))
|
||||
.ok()
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user