You've already forked flix
Improve model
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "flix-cli"
|
||||
version = "0.0.3"
|
||||
version = "0.0.4"
|
||||
|
||||
categories = ["command-line-utilities"]
|
||||
description = "CLI for interacting with flix media"
|
||||
|
||||
@@ -5,32 +5,32 @@ 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
|
||||
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,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::path::Path;
|
||||
|
||||
use flix_tmdb::Client;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
@@ -41,7 +43,7 @@ async fn main() -> Result<()> {
|
||||
let output = output
|
||||
.as_ref()
|
||||
.map(|p| p.as_path())
|
||||
.unwrap_or(object.default_filename());
|
||||
.unwrap_or(Path::new("flix.toml"));
|
||||
|
||||
let mut file = if *force {
|
||||
fs::File::create(output).await
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::path::Path;
|
||||
|
||||
use flix::model::{
|
||||
Collection, Episode, GenericCollection, GenericEpisode, GenericMovie, GenericSeason,
|
||||
GenericShow, Movie, Season, Show, TmdbCollection, TmdbMovie, TmdbShow,
|
||||
@@ -23,16 +21,6 @@ pub enum 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> {
|
||||
Ok(match self {
|
||||
TmdbObject::Collection(tmdb) => toml::to_string(&Collection {
|
||||
@@ -68,6 +56,7 @@ impl TmdbObject {
|
||||
})?,
|
||||
TmdbObject::Season(tmdb) => toml::to_string(&Season {
|
||||
season: GenericSeason {
|
||||
number: tmdb.season_number,
|
||||
name: tmdb.name,
|
||||
overview: tmdb.overview,
|
||||
air_date: tmdb.air_date,
|
||||
@@ -75,6 +64,7 @@ impl TmdbObject {
|
||||
})?,
|
||||
TmdbObject::Episode(tmdb) => toml::to_string(&Episode {
|
||||
episode: GenericEpisode {
|
||||
number: tmdb.episode_number,
|
||||
name: tmdb.name,
|
||||
overview: tmdb.overview,
|
||||
air_date: tmdb.air_date,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "flix"
|
||||
version = "0.0.3"
|
||||
version = "0.0.4"
|
||||
|
||||
categories = []
|
||||
description = "Types for storing persistent data about media"
|
||||
|
||||
@@ -10,6 +10,8 @@ pub struct Episode {
|
||||
/// The generic episode data
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct GenericEpisode {
|
||||
/// The episode's number
|
||||
pub number: u32,
|
||||
/// The episode's name
|
||||
pub name: String,
|
||||
/// The episode's overview
|
||||
|
||||
@@ -10,6 +10,8 @@ pub struct Season {
|
||||
/// The generic season data
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct GenericSeason {
|
||||
/// The season's number
|
||||
pub number: u32,
|
||||
/// The season's name
|
||||
pub name: String,
|
||||
/// The season's overview
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "flix-tmdb"
|
||||
version = "0.0.3"
|
||||
version = "0.0.4"
|
||||
|
||||
categories = []
|
||||
description = "Clients and models for fetching data from TMDB"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@ use chrono::NaiveDate;
|
||||
#[derive(Debug, Clone, serde::Deserialize)]
|
||||
pub struct Episode {
|
||||
/// The episode's number
|
||||
pub episode_number: i32,
|
||||
pub episode_number: u32,
|
||||
/// The episode's name
|
||||
pub name: String,
|
||||
/// The episode's overview
|
||||
|
||||
@@ -19,7 +19,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
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::Episode;
|
||||
#[derive(Debug, Clone, serde::Deserialize)]
|
||||
pub struct Season {
|
||||
/// The season's number
|
||||
pub season_number: i32,
|
||||
pub season_number: u32,
|
||||
/// The season's name
|
||||
pub name: String,
|
||||
/// The season's overview
|
||||
|
||||
@@ -18,7 +18,7 @@ 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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user