6 Commits

26 changed files with 584 additions and 408 deletions
Generated
+220 -280
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -34,12 +34,13 @@ overflow-checks = true
strip = "debuginfo"
[workspace.dependencies]
flix = { path = "crates/flix", version = "=0.0.2", default-features = false }
flix-tmdb = { path = "crates/tmdb", version = "=0.0.2", default-features = false }
flix = { path = "crates/flix", version = "=0.0.8", default-features = false }
flix-tmdb = { path = "crates/tmdb", version = "=0.0.8", default-features = false }
anyhow = { version = "^1", default-features = false }
chrono = { version = "^0.4", default-features = false }
clap = { version = "^4", default-features = false, features = ["std"] }
futures = { version = "^0.3", default-features = false }
home = { version = "^0.5", default-features = false }
reqwest = { version = "^0.12", default-features = false }
serde = { version = "^1", default-features = false }
+2 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flix-cli"
version = "0.0.2"
version = "0.0.8"
categories = ["command-line-utilities"]
description = "CLI for interacting with flix media"
@@ -48,5 +48,6 @@ clap = { workspace = true, features = [
] }
home = { workspace = true }
serde = { workspace = true, features = ["derive"] }
futures = { workspace = true }
tokio = { workspace = true, features = ["rt", "fs", "macros"] }
toml = { workspace = true, features = ["display", "parse"] }
+22 -13
View File
@@ -7,9 +7,9 @@ pub mod tmdb;
#[derive(Parser)]
#[command(version, about, long_about = None)]
pub struct Cli {
/// Use a custom config file [default: ~/.flix]
#[arg(short, long, value_name = "FILE")]
config: Option<PathBuf>,
/// Use a custom config file
#[arg(short, long, value_name = "FILE", default_value = "~/.flix")]
config: PathBuf,
#[command(subcommand)]
command: Command,
@@ -17,17 +17,14 @@ pub struct Cli {
impl Cli {
pub fn config_path(&self) -> PathBuf {
match self.config.as_ref() {
Some(path) => match path.strip_prefix("~/") {
Ok(path) => expect_home_dir().join(path),
Err(_) => path.to_owned(),
},
None => expect_home_dir().join(".flix"),
match self.config.strip_prefix("~/") {
Ok(path) => expect_home_dir().join(path),
Err(_) => self.config.to_owned(),
}
}
pub fn command(&self) -> &Command {
&self.command
pub fn command(self) -> Command {
self.command
}
}
@@ -45,12 +42,18 @@ pub enum Command {
force: bool,
/// Change the destination
#[arg(short, long, value_name = "FILE")]
output: Option<PathBuf>,
#[arg(short, long, value_name = "FILE", default_value = "flix.toml")]
output: PathBuf,
#[command(subcommand)]
command: BackendCommand,
},
/// Update a flix manifest
Update {
/// Change the destination
#[arg(short, long, value_name = "FILE", default_value = "flix.toml")]
output: PathBuf,
},
}
#[derive(Subcommand)]
@@ -62,6 +65,12 @@ pub enum BackendCommand {
},
}
impl From<tmdb::Command> for BackendCommand {
fn from(value: tmdb::Command) -> Self {
Self::Tmdb { command: value }
}
}
fn expect_home_dir() -> PathBuf {
#[allow(clippy::expect_used)]
home::home_dir().expect("you do not have a home directory")
+11 -8
View File
@@ -5,32 +5,35 @@ pub enum Command {
/// Process a TMDB collection
Collection {
#[arg(value_name = "TMDB_ID")]
id: i32,
id: u32,
},
/// Process a TMDB movie
Movie {
#[arg(value_name = "TMDB_ID")]
id: i32,
id: u32,
},
/// Process a TMDB show
Show {
#[arg(value_name = "TMDB_ID")]
id: i32,
id: u32,
},
/// Process a TMDB season
Season {
#[arg(value_name = "TMDB_ID")]
id: i32,
id: u32,
#[arg(value_name = "SEASON_NUM")]
season: i32,
season: u32,
},
/// Process a TMDB episode
#[command(trailing_var_arg = true)]
Episode {
#[arg(value_name = "TMDB_ID")]
id: i32,
id: u32,
#[arg(value_name = "SEASON_NUM")]
season: i32,
season: u32,
#[arg(value_name = "EPISODE_NUM")]
episode: i32,
episode: u32,
#[arg(value_name = "...")]
episodes: Vec<u32>,
},
}
+57 -31
View File
@@ -1,17 +1,20 @@
use std::path::Path;
use flix_tmdb::Client;
use anyhow::{Context, Result};
use clap::Parser;
use tokio::fs;
use tokio::io::AsyncWriteExt;
mod cli;
use cli::{BackendCommand, Cli, Command};
mod config;
use config::Config;
use tokio::io::AsyncWriteExt;
mod run;
use run::flix::FlixObject;
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
@@ -25,41 +28,64 @@ async fn main() -> Result<()> {
let client = Client::new(config.tmdb().bearer_token().to_owned());
match cli.command() {
Command::Print { command } => match command {
BackendCommand::Tmdb { command } => {
let object = run::tmdb::TmdbObject::fetch(&client, command).await?;
println!("{}", object.serialize().context("failed to serialize")?)
}
},
Command::Print { command } => exec_print(client, command).await?,
Command::Write {
force,
output,
command,
} => match command {
BackendCommand::Tmdb { command } => {
let object = run::tmdb::TmdbObject::fetch(&client, command).await?;
let output = output
.as_ref()
.map(|p| p.as_path())
.unwrap_or(object.default_filename());
let mut file = if *force {
fs::File::create(output).await
} else {
fs::File::create_new(output).await
}
.with_context(|| format!("could not create file at path {}", output.display()))?;
file.write_all(
object
.serialize()
.context("failed to serialize tmdb object")?
.as_bytes(),
)
.await
.with_context(|| format!("could not write to file at path {}", output.display()))?;
}
},
} => exec_write(client, force, &output, command).await?,
Command::Update { output } => exec_update(client, &output).await?,
}
Ok(())
}
async fn exec_print(client: Client, command: BackendCommand) -> Result<()> {
match command {
BackendCommand::Tmdb { command } => {
let object = run::tmdb::TmdbObject::fetch(&client, command).await?;
println!("{}", object.serialize().context("failed to serialize")?)
}
}
Ok(())
}
async fn exec_write(
client: Client,
force: bool,
output: &Path,
command: BackendCommand,
) -> Result<()> {
match command {
BackendCommand::Tmdb { command } => {
let object = run::tmdb::TmdbObject::fetch(&client, command).await?;
let mut file = if force {
fs::File::create(output).await
} else {
fs::File::create_new(output).await
}
.with_context(|| format!("could not create file at path {}", output.display()))?;
file.write_all(
object
.serialize()
.context("failed to serialize tmdb object")?
.as_bytes(),
)
.await
.with_context(|| format!("could not write to file at path {}", output.display()))?;
}
}
Ok(())
}
async fn exec_update(client: Client, output: &Path) -> Result<()> {
let content = fs::read_to_string(output)
.await
.with_context(|| format!("failed to read file at path: {}", output.display()))?;
let object: FlixObject = toml::from_str(&content)
.with_context(|| format!("failed to deserialize flix file: {}", output.display()))?;
let command = object.backend_command()?;
exec_write(client, true, output, command).await
}
+75
View File
@@ -0,0 +1,75 @@
use flix::model::{Collection, Episode, Movie, Season, Show, Verse};
use anyhow::{Result, anyhow, bail};
use crate::cli::BackendCommand;
use crate::cli::tmdb;
#[derive(Debug, serde::Deserialize)]
#[serde(untagged)]
pub enum FlixObject {
Collection(Collection),
Movie(Movie),
Show(Show),
Season(Season),
Episode(Episode),
// DEAD CODE: The TMDB backend does not support Verses
#[allow(dead_code)]
Verse(Verse),
}
impl FlixObject {
pub fn backend_command(&self) -> Result<BackendCommand> {
Ok(match self {
FlixObject::Collection(collection) => {
let Some(ref tmdb) = collection.tmdb else {
bail!("missing tmdb data")
};
tmdb::Command::Collection { id: tmdb.id.into() }.into()
}
FlixObject::Movie(movie) => {
let Some(ref tmdb) = movie.tmdb else {
bail!("missing tmdb data")
};
tmdb::Command::Movie { id: tmdb.id.into() }.into()
}
FlixObject::Show(show) => {
let Some(ref tmdb) = show.tmdb else {
bail!("missing tmdb data")
};
tmdb::Command::Show { id: tmdb.id.into() }.into()
}
FlixObject::Season(season) => {
let Some(ref tmdb) = season.tmdb else {
bail!("missing tmdb data")
};
tmdb::Command::Season {
id: tmdb.show_id.into(),
season: season.season.number,
}
.into()
}
FlixObject::Episode(episode) => {
let Some(ref tmdb) = episode.tmdb else {
bail!("missing tmdb data")
};
tmdb::Command::Episode {
id: tmdb.show_id.into(),
season: episode.episode.season,
episode: episode
.episode
.number
.primary_episode_number()
.ok_or_else(|| {
anyhow!("the episode does not have a primary episode number")
})?,
episodes: episode.episode.number.additional_episode_numbers(),
}
.into()
}
FlixObject::Verse(_) => {
bail!("verses are not handled")
}
})
}
}
+1
View File
@@ -1 +1,2 @@
pub mod flix;
pub mod tmdb;
+60 -34
View File
@@ -1,16 +1,16 @@
use std::path::Path;
use flix::model::{
Collection, Episode, GenericCollection, GenericEpisode, GenericMovie, GenericSeason,
GenericShow, Movie, Season, Show, TmdbCollection, TmdbMovie, TmdbShow,
Collection, Episode, EpisodeNumber, GenericCollection, GenericEpisode, GenericMovie,
GenericSeason, GenericShow, Movie, Season, Show, TmdbCollection, TmdbEpisode, TmdbMovie,
TmdbSeason, TmdbShow,
};
use flix_tmdb::Client;
use flix_tmdb::model::{
Collection as TCollection, Episode as TEpisode, Movie as TMovie, Season as TSeason,
Show as TShow,
Show as TShow, ShowId,
};
use anyhow::{Context, Result};
use futures::{StreamExt, TryStreamExt, stream};
use crate::cli::tmdb::Command;
@@ -18,26 +18,16 @@ pub enum TmdbObject {
Collection(TCollection),
Movie(TMovie),
Show(TShow),
Season(TSeason),
Episode(TEpisode),
Season(TSeason, ShowId),
Episode(TEpisode, Vec<u32>, u32, ShowId),
}
impl TmdbObject {
pub fn default_filename(&self) -> &'static Path {
Path::new(match self {
TmdbObject::Collection(_) => "collection.toml",
TmdbObject::Movie(_) => "movie.toml",
TmdbObject::Show(_) => "show.toml",
TmdbObject::Season(_) => "season.toml",
TmdbObject::Episode(_) => "episode.toml",
})
}
pub fn serialize(self) -> Result<String> {
Ok(match self {
TmdbObject::Collection(tmdb) => toml::to_string(&Collection {
collection: GenericCollection {
name: tmdb.name,
title: tmdb.title,
overview: tmdb.overview,
},
tmdb: Some(TmdbCollection { id: tmdb.id }),
@@ -46,6 +36,7 @@ impl TmdbObject {
movie: GenericMovie {
title: tmdb.title,
overview: tmdb.overview,
genres: tmdb.genres.iter().cloned().map(|g| g.name).collect(),
release_date: tmdb.release_date,
},
tmdb: Some(TmdbMovie {
@@ -55,8 +46,9 @@ impl TmdbObject {
})?,
TmdbObject::Show(tmdb) => toml::to_string(&Show {
show: GenericShow {
name: tmdb.name,
title: tmdb.title,
overview: tmdb.overview,
genres: tmdb.genres.iter().cloned().map(|g| g.name).collect(),
air_date: tmdb.first_air_date,
},
tmdb: Some(TmdbShow {
@@ -64,27 +56,43 @@ impl TmdbObject {
genres: tmdb.genres.iter().map(|g| g.id).collect(),
}),
})?,
TmdbObject::Season(tmdb) => toml::to_string(&Season {
TmdbObject::Season(tmdb, show_id) => toml::to_string(&Season {
season: GenericSeason {
name: tmdb.name,
overview: tmdb.overview,
air_date: tmdb.air_date,
},
})?,
TmdbObject::Episode(tmdb) => toml::to_string(&Episode {
episode: GenericEpisode {
name: tmdb.name,
number: tmdb.season_number,
title: tmdb.title,
overview: tmdb.overview,
air_date: tmdb.air_date,
},
tmdb: Some(TmdbSeason { show_id }),
})?,
TmdbObject::Episode(tmdb, mut episode_numbers, season_number, show_id) => {
toml::to_string(&Episode {
episode: GenericEpisode {
number: if episode_numbers.is_empty() {
EpisodeNumber::Single {
number: tmdb.episode_number,
}
} else {
episode_numbers.insert(0, tmdb.episode_number);
EpisodeNumber::Multiple {
numbers: episode_numbers,
}
},
season: season_number,
title: tmdb.title,
overview: tmdb.overview,
air_date: tmdb.air_date,
},
tmdb: Some(TmdbEpisode { show_id }),
})?
}
})
}
}
impl TmdbObject {
pub async fn fetch(client: &Client, command: &Command) -> Result<Self> {
Ok(match *command {
pub async fn fetch(client: &Client, command: Command) -> Result<Self> {
Ok(match command {
Command::Collection { id } => Self::Collection(
client
.collections()
@@ -112,20 +120,38 @@ impl TmdbObject {
.get_details(id, season, None)
.await
.with_context(|| format!("could not get show details for '{id}' S{season}"))?,
id.into(),
),
Command::Episode {
id,
season,
episode,
} => Self::Episode(
client
episodes,
} => {
let mut episode = client
.episodes()
.get_details(id, season, episode, None)
.await
.with_context(|| {
format!("could not get show details for '{id}' S{season}E{episode}")
})?,
),
})?;
let title = stream::once(async { Ok(episode.title) })
.chain(stream::iter(episodes.clone()).then(|episode| async move {
client
.episodes()
.get_details(id, season, episode, None)
.await
.with_context(|| {
format!("could not get show details for '{id}' S{season}E{episode}")
})
.map(|episode| episode.title)
}))
.try_collect::<Vec<_>>()
.await?
.join(" + ");
episode.title = title;
Self::Episode(episode, episodes, season, id.into())
}
})
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flix"
version = "0.0.2"
version = "0.0.8"
categories = []
description = "Types for storing persistent data about media"
+2 -2
View File
@@ -15,8 +15,8 @@ pub struct Collection {
/// The generic collection data
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericCollection {
/// The collection's name
pub name: String,
/// The collection's title
pub title: String,
/// The collection's overview
pub overview: String,
}
+56 -2
View File
@@ -1,3 +1,6 @@
#[cfg(feature = "tmdb")]
use flix_tmdb::model::ShowId;
use chrono::NaiveDate;
/// An Episode container
@@ -5,15 +8,66 @@ use chrono::NaiveDate;
pub struct Episode {
/// The generic episode data
pub episode: GenericEpisode,
/// The TMDB episode data
#[cfg(feature = "tmdb")]
pub tmdb: Option<TmdbEpisode>,
}
/// A wrapper for handling single and multi-episode entries
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum EpisodeNumber {
/// The entry contains a single episode
Single {
/// The episode's number
number: u32,
},
/// The entry contains multiple episodes
Multiple {
/// The list of episode numbers
numbers: Vec<u32>,
},
}
impl EpisodeNumber {
/// Get the primary episode number of this episode
pub fn primary_episode_number(&self) -> Option<u32> {
match self {
EpisodeNumber::Single { number } => Some(*number),
EpisodeNumber::Multiple { numbers } => numbers.first().copied(),
}
}
/// Get additional episode numbers of this episode
pub fn additional_episode_numbers(&self) -> Vec<u32> {
match self {
EpisodeNumber::Single { number: _ } => vec![],
EpisodeNumber::Multiple { numbers } => numbers.iter().skip(1).copied().collect(),
}
}
}
/// The generic episode data
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericEpisode {
/// The episode's name
pub name: String,
/// The episode's number(s)
#[serde(flatten)]
pub number: EpisodeNumber,
/// The episode's season's number
pub season: u32,
/// The episode's title
pub title: String,
/// The episode's overview
pub overview: String,
/// The episode's air date
pub air_date: NaiveDate,
}
/// The TMDB show data
#[cfg(feature = "tmdb")]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct TmdbEpisode {
/// The episodes's show's TMDB ID
pub show_id: ShowId,
}
+2
View File
@@ -21,6 +21,8 @@ pub struct GenericMovie {
pub title: String,
/// The movie's overview
pub overview: String,
/// The movie's genres
pub genres: Vec<String>,
/// The movie's release date
pub release_date: NaiveDate,
}
+19 -2
View File
@@ -1,3 +1,6 @@
#[cfg(feature = "tmdb")]
use flix_tmdb::model::ShowId;
use chrono::NaiveDate;
/// A Season container
@@ -5,15 +8,29 @@ use chrono::NaiveDate;
pub struct Season {
/// The generic season data
pub season: GenericSeason,
/// The TMDB season data
#[cfg(feature = "tmdb")]
pub tmdb: Option<TmdbSeason>,
}
/// The generic season data
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericSeason {
/// The season's name
pub name: String,
/// The season's number
pub number: u32,
/// The season's title
pub title: String,
/// The season's overview
pub overview: String,
/// The season's air date
pub air_date: NaiveDate,
}
/// The TMDB show data
#[cfg(feature = "tmdb")]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct TmdbSeason {
/// The season's show's TMDB ID
pub show_id: ShowId,
}
+4 -2
View File
@@ -17,10 +17,12 @@ pub struct Show {
/// The generic show data
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericShow {
/// The show's name
pub name: String,
/// The show's title
pub title: String,
/// The show's overview
pub overview: String,
/// The show's genres
pub genres: Vec<String>,
/// The show's air date
pub air_date: NaiveDate,
}
+11 -3
View File
@@ -1,5 +1,5 @@
#[cfg(feature = "tmdb")]
use flix_tmdb::model::{MovieId, ShowId};
use flix_tmdb::model::{CollectionId, MovieId, ShowId};
/// A Verse container
#[derive(Debug, serde::Serialize, serde::Deserialize)]
@@ -15,8 +15,8 @@ pub struct Verse {
/// The generic verse data
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericVerse {
/// The verse's name
pub name: String,
/// The verse's title
pub title: String,
/// The verse's overview
pub overview: String,
}
@@ -25,8 +25,16 @@ pub struct GenericVerse {
#[cfg(feature = "tmdb")]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct TmdbVerse {
/// The list of collection TMDB IDs in the verse
#[serde(default)]
pub collections: Vec<CollectionId>,
/// The list of movie TMDB IDs in the verse
#[serde(default)]
pub movies: Vec<MovieId>,
/// The list of show TMDB IDs in the verse
#[serde(default)]
pub shows: Vec<ShowId>,
/// The list of sub-verse names
#[serde(default)]
pub verses: Vec<String>,
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flix-tmdb"
version = "0.0.2"
version = "0.0.8"
categories = []
description = "Clients and models for fetching data from TMDB"
+2 -2
View File
@@ -22,8 +22,8 @@ impl Client {
pub async fn get_details(
&self,
id: impl Into<ShowId>,
season: impl Into<i32>,
episode: impl Into<i32>,
season: impl Into<u32>,
episode: impl Into<u32>,
language: Option<&str>,
) -> Result<Episode, Error> {
Ok(self
+1 -1
View File
@@ -22,7 +22,7 @@ impl Client {
pub async fn get_details(
&self,
id: impl Into<ShowId>,
season: impl Into<i32>,
season: impl Into<u32>,
language: Option<&str>,
) -> Result<Season, Error> {
Ok(self
+5 -4
View File
@@ -1,12 +1,13 @@
use super::{CollectionId, MovieId};
/// A deserialized Collection from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Collection {
/// The collection's TMDB ID
pub id: CollectionId,
/// The collection's name
pub name: String,
/// The collection's title
#[serde(rename = "name")]
pub title: String,
/// The collection's overview
pub overview: String,
/// The list of movies that are part of this collection
@@ -15,7 +16,7 @@ pub struct Collection {
}
/// A deserialized collection item from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Item {
/// The movie's TMDB ID
pub id: MovieId,
+5 -4
View File
@@ -1,12 +1,13 @@
use chrono::NaiveDate;
/// A deserialized Episode from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Episode {
/// The episode's number
pub episode_number: i32,
/// The episode's name
pub name: String,
pub episode_number: u32,
/// The episode's title
#[serde(rename = "name")]
pub title: String,
/// The episode's overview
pub overview: String,
/// The episode's air date
+2 -2
View File
@@ -1,7 +1,7 @@
use super::id::{MovieGenreId, ShowGenreId};
/// A deserialized movie Genre from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct MovieGenre {
/// The genre's TMDB ID
pub id: MovieGenreId,
@@ -10,7 +10,7 @@ pub struct MovieGenre {
}
/// A deserialized show Genre from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct ShowGenre {
/// The genre's TMDB ID
pub id: ShowGenreId,
+8 -1
View File
@@ -1,4 +1,5 @@
use core::fmt;
use core::hash::{Hash, Hasher};
use core::marker::PhantomData;
/// The TMDB ID type of a movie genre
@@ -19,7 +20,7 @@ pub enum Movie {}
pub enum Show {}
/// The inner type of TmdbId
pub type Inner = i32;
pub type Inner = u32;
/// Wraps an ID from TMDB, the generic parameter is to enforce that
/// IDs for different types of media are not interchangeable
@@ -81,3 +82,9 @@ impl<T> PartialEq for TmdbId<T> {
}
impl<T> Eq for TmdbId<T> {}
impl<T> Hash for TmdbId<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.inner.hash(state);
}
}
+3 -3
View File
@@ -3,7 +3,7 @@ use chrono::NaiveDate;
use super::{CollectionId, MovieGenre, MovieId};
/// A deserialized Movie from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Movie {
/// The movie's TMDB ID
pub id: MovieId,
@@ -23,14 +23,14 @@ pub struct Movie {
}
/// A deserialized movie's collection from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct InCollection {
/// The collection's TMDB ID
pub id: CollectionId,
}
/// A deserialized movie status from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, Copy, serde::Deserialize)]
pub enum MovieStatus {
/// The movie was cancelled
#[serde(rename = "Canceled")]
+5 -4
View File
@@ -3,12 +3,13 @@ use chrono::NaiveDate;
use super::Episode;
/// A deserialized Season from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Season {
/// The season's number
pub season_number: i32,
/// The season's name
pub name: String,
pub season_number: u32,
/// The season's title
#[serde(rename = "name")]
pub title: String,
/// The season's overview
pub overview: String,
/// The season's air date
+6 -5
View File
@@ -3,12 +3,13 @@ use chrono::NaiveDate;
use super::{ShowGenre, ShowId};
/// A deserialized Show from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Show {
/// The show's TMDB ID
pub id: ShowId,
/// The show's name
pub name: String,
/// The show's title
#[serde(rename = "name")]
pub title: String,
/// The show's overview
pub overview: String,
/// The list of genres this show belongs to
@@ -18,13 +19,13 @@ pub struct Show {
/// The show's last air date
pub last_air_date: NaiveDate,
/// The number of seasons in this show
pub number_of_seasons: i32,
pub number_of_seasons: u32,
/// The show's status
pub status: ShowStatus,
}
/// A deserialized show Status from the TMDB API
#[derive(Debug, serde::Deserialize)]
#[derive(Debug, Clone, Copy, serde::Deserialize)]
pub enum ShowStatus {
/// The show is returning
#[serde(rename = "Returning Series")]