1 Commits

Author SHA1 Message Date
davidskrundz 62e933448c Improve model 2025-05-07 20:22:05 -06:00
16 changed files with 32 additions and 36 deletions
Generated
+3 -3
View File
@@ -214,7 +214,7 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]] [[package]]
name = "flix" name = "flix"
version = "0.0.3" version = "0.0.4"
dependencies = [ dependencies = [
"chrono", "chrono",
"flix-tmdb", "flix-tmdb",
@@ -224,7 +224,7 @@ dependencies = [
[[package]] [[package]]
name = "flix-cli" name = "flix-cli"
version = "0.0.3" version = "0.0.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@@ -238,7 +238,7 @@ dependencies = [
[[package]] [[package]]
name = "flix-tmdb" name = "flix-tmdb"
version = "0.0.3" version = "0.0.4"
dependencies = [ dependencies = [
"chrono", "chrono",
"reqwest", "reqwest",
+2 -2
View File
@@ -34,8 +34,8 @@ overflow-checks = true
strip = "debuginfo" strip = "debuginfo"
[workspace.dependencies] [workspace.dependencies]
flix = { path = "crates/flix", version = "=0.0.3", default-features = false } flix = { path = "crates/flix", version = "=0.0.4", default-features = false }
flix-tmdb = { path = "crates/tmdb", version = "=0.0.3", default-features = false } flix-tmdb = { path = "crates/tmdb", version = "=0.0.4", default-features = false }
anyhow = { version = "^1", default-features = false } anyhow = { version = "^1", default-features = false }
chrono = { version = "^0.4", default-features = false } chrono = { version = "^0.4", default-features = false }
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "flix-cli" name = "flix-cli"
version = "0.0.3" version = "0.0.4"
categories = ["command-line-utilities"] categories = ["command-line-utilities"]
description = "CLI for interacting with flix media" description = "CLI for interacting with flix media"
+8 -8
View File
@@ -5,32 +5,32 @@ pub enum Command {
/// Process a TMDB collection /// Process a TMDB collection
Collection { Collection {
#[arg(value_name = "TMDB_ID")] #[arg(value_name = "TMDB_ID")]
id: i32, id: u32,
}, },
/// Process a TMDB movie /// Process a TMDB movie
Movie { Movie {
#[arg(value_name = "TMDB_ID")] #[arg(value_name = "TMDB_ID")]
id: i32, id: u32,
}, },
/// Process a TMDB show /// Process a TMDB show
Show { Show {
#[arg(value_name = "TMDB_ID")] #[arg(value_name = "TMDB_ID")]
id: i32, id: u32,
}, },
/// Process a TMDB season /// Process a TMDB season
Season { Season {
#[arg(value_name = "TMDB_ID")] #[arg(value_name = "TMDB_ID")]
id: i32, id: u32,
#[arg(value_name = "SEASON_NUM")] #[arg(value_name = "SEASON_NUM")]
season: i32, season: u32,
}, },
/// Process a TMDB episode /// Process a TMDB episode
Episode { Episode {
#[arg(value_name = "TMDB_ID")] #[arg(value_name = "TMDB_ID")]
id: i32, id: u32,
#[arg(value_name = "SEASON_NUM")] #[arg(value_name = "SEASON_NUM")]
season: i32, season: u32,
#[arg(value_name = "EPISODE_NUM")] #[arg(value_name = "EPISODE_NUM")]
episode: i32, episode: u32,
}, },
} }
+3 -1
View File
@@ -1,3 +1,5 @@
use std::path::Path;
use flix_tmdb::Client; use flix_tmdb::Client;
use anyhow::{Context, Result}; use anyhow::{Context, Result};
@@ -41,7 +43,7 @@ async fn main() -> Result<()> {
let output = output let output = output
.as_ref() .as_ref()
.map(|p| p.as_path()) .map(|p| p.as_path())
.unwrap_or(object.default_filename()); .unwrap_or(Path::new("flix.toml"));
let mut file = if *force { let mut file = if *force {
fs::File::create(output).await fs::File::create(output).await
+2 -12
View File
@@ -1,5 +1,3 @@
use std::path::Path;
use flix::model::{ use flix::model::{
Collection, Episode, GenericCollection, GenericEpisode, GenericMovie, GenericSeason, Collection, Episode, GenericCollection, GenericEpisode, GenericMovie, GenericSeason,
GenericShow, Movie, Season, Show, TmdbCollection, TmdbMovie, TmdbShow, GenericShow, Movie, Season, Show, TmdbCollection, TmdbMovie, TmdbShow,
@@ -23,16 +21,6 @@ pub enum TmdbObject {
} }
impl TmdbObject { 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> { pub fn serialize(self) -> Result<String> {
Ok(match self { Ok(match self {
TmdbObject::Collection(tmdb) => toml::to_string(&Collection { TmdbObject::Collection(tmdb) => toml::to_string(&Collection {
@@ -68,6 +56,7 @@ impl TmdbObject {
})?, })?,
TmdbObject::Season(tmdb) => toml::to_string(&Season { TmdbObject::Season(tmdb) => toml::to_string(&Season {
season: GenericSeason { season: GenericSeason {
number: tmdb.season_number,
name: tmdb.name, name: tmdb.name,
overview: tmdb.overview, overview: tmdb.overview,
air_date: tmdb.air_date, air_date: tmdb.air_date,
@@ -75,6 +64,7 @@ impl TmdbObject {
})?, })?,
TmdbObject::Episode(tmdb) => toml::to_string(&Episode { TmdbObject::Episode(tmdb) => toml::to_string(&Episode {
episode: GenericEpisode { episode: GenericEpisode {
number: tmdb.episode_number,
name: tmdb.name, name: tmdb.name,
overview: tmdb.overview, overview: tmdb.overview,
air_date: tmdb.air_date, air_date: tmdb.air_date,
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "flix" name = "flix"
version = "0.0.3" version = "0.0.4"
categories = [] categories = []
description = "Types for storing persistent data about media" description = "Types for storing persistent data about media"
+2
View File
@@ -10,6 +10,8 @@ pub struct Episode {
/// The generic episode data /// The generic episode data
#[derive(Debug, serde::Serialize, serde::Deserialize)] #[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericEpisode { pub struct GenericEpisode {
/// The episode's number
pub number: u32,
/// The episode's name /// The episode's name
pub name: String, pub name: String,
/// The episode's overview /// The episode's overview
+2
View File
@@ -10,6 +10,8 @@ pub struct Season {
/// The generic season data /// The generic season data
#[derive(Debug, serde::Serialize, serde::Deserialize)] #[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericSeason { pub struct GenericSeason {
/// The season's number
pub number: u32,
/// The season's name /// The season's name
pub name: String, pub name: String,
/// The season's overview /// The season's overview
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "flix-tmdb" name = "flix-tmdb"
version = "0.0.3" version = "0.0.4"
categories = [] categories = []
description = "Clients and models for fetching data from TMDB" description = "Clients and models for fetching data from TMDB"
+2 -2
View File
@@ -22,8 +22,8 @@ impl Client {
pub async fn get_details( pub async fn get_details(
&self, &self,
id: impl Into<ShowId>, id: impl Into<ShowId>,
season: impl Into<i32>, season: impl Into<u32>,
episode: impl Into<i32>, episode: impl Into<u32>,
language: Option<&str>, language: Option<&str>,
) -> Result<Episode, Error> { ) -> Result<Episode, Error> {
Ok(self Ok(self
+1 -1
View File
@@ -22,7 +22,7 @@ impl Client {
pub async fn get_details( pub async fn get_details(
&self, &self,
id: impl Into<ShowId>, id: impl Into<ShowId>,
season: impl Into<i32>, season: impl Into<u32>,
language: Option<&str>, language: Option<&str>,
) -> Result<Season, Error> { ) -> Result<Season, Error> {
Ok(self Ok(self
+1 -1
View File
@@ -4,7 +4,7 @@ use chrono::NaiveDate;
#[derive(Debug, Clone, serde::Deserialize)] #[derive(Debug, Clone, serde::Deserialize)]
pub struct Episode { pub struct Episode {
/// The episode's number /// The episode's number
pub episode_number: i32, pub episode_number: u32,
/// The episode's name /// The episode's name
pub name: String, pub name: String,
/// The episode's overview /// The episode's overview
+1 -1
View File
@@ -19,7 +19,7 @@ pub enum Movie {}
pub enum Show {} pub enum Show {}
/// The inner type of TmdbId /// 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 /// Wraps an ID from TMDB, the generic parameter is to enforce that
/// IDs for different types of media are not interchangeable /// IDs for different types of media are not interchangeable
+1 -1
View File
@@ -6,7 +6,7 @@ use super::Episode;
#[derive(Debug, Clone, serde::Deserialize)] #[derive(Debug, Clone, serde::Deserialize)]
pub struct Season { pub struct Season {
/// The season's number /// The season's number
pub season_number: i32, pub season_number: u32,
/// The season's name /// The season's name
pub name: String, pub name: String,
/// The season's overview /// The season's overview
+1 -1
View File
@@ -18,7 +18,7 @@ pub struct Show {
/// The show's last air date /// The show's last air date
pub last_air_date: NaiveDate, pub last_air_date: NaiveDate,
/// The number of seasons in this show /// The number of seasons in this show
pub number_of_seasons: i32, pub number_of_seasons: u32,
/// The show's status /// The show's status
pub status: ShowStatus, pub status: ShowStatus,
} }