4 Commits

Author SHA1 Message Date
davidskrundz 62e933448c Improve model 2025-05-07 20:22:05 -06:00
davidskrundz 492f054e23 Add genre strings 2025-05-04 22:30:50 -06:00
davidskrundz 343978e3f2 Strip derivable metadata 2025-05-03 18:38:53 -06:00
davidskrundz 45b0a5e601 Expose TmdbId 2025-05-03 18:08:39 -06:00
23 changed files with 54 additions and 56 deletions
Generated
+3 -3
View File
@@ -214,7 +214,7 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "flix"
version = "0.0.1"
version = "0.0.4"
dependencies = [
"chrono",
"flix-tmdb",
@@ -224,7 +224,7 @@ dependencies = [
[[package]]
name = "flix-cli"
version = "0.0.1"
version = "0.0.4"
dependencies = [
"anyhow",
"clap",
@@ -238,7 +238,7 @@ dependencies = [
[[package]]
name = "flix-tmdb"
version = "0.0.1"
version = "0.0.4"
dependencies = [
"chrono",
"reqwest",
+2 -2
View File
@@ -34,8 +34,8 @@ overflow-checks = true
strip = "debuginfo"
[workspace.dependencies]
flix = { path = "crates/flix", version = "=0.0.1", default-features = false }
flix-tmdb = { path = "crates/tmdb", version = "=0.0.1", default-features = false }
flix = { path = "crates/flix", version = "=0.0.4", default-features = false }
flix-tmdb = { path = "crates/tmdb", version = "=0.0.4", default-features = false }
anyhow = { version = "^1", default-features = false }
chrono = { version = "^0.4", default-features = false }
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flix-cli"
version = "0.0.1"
version = "0.0.4"
categories = ["command-line-utilities"]
description = "CLI for interacting with flix media"
+8 -8
View File
@@ -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,
},
}
+3 -1
View File
@@ -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
+2 -13
View File
@@ -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 {
@@ -46,11 +34,11 @@ 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 {
id: tmdb.id,
collection: tmdb.collection.map(|c| c.id),
genres: tmdb.genres.iter().map(|g| g.id).collect(),
}),
})?,
@@ -58,6 +46,7 @@ impl TmdbObject {
show: GenericShow {
name: tmdb.name,
overview: tmdb.overview,
genres: tmdb.genres.iter().cloned().map(|g| g.name).collect(),
air_date: tmdb.first_air_date,
},
tmdb: Some(TmdbShow {
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flix"
version = "0.0.1"
version = "0.0.4"
categories = []
description = "Types for storing persistent data about media"
+1 -1
View File
@@ -11,7 +11,7 @@ pub struct Episode {
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericEpisode {
/// The episode's number
pub number: i32,
pub number: u32,
/// The episode's name
pub name: String,
/// The episode's overview
+3 -3
View File
@@ -1,5 +1,5 @@
#[cfg(feature = "tmdb")]
use flix_tmdb::model::{CollectionId, MovieGenreId, MovieId};
use flix_tmdb::model::{MovieGenreId, MovieId};
use chrono::NaiveDate;
@@ -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,
}
@@ -31,8 +33,6 @@ pub struct GenericMovie {
pub struct TmdbMovie {
/// The movie's TMDB ID
pub id: MovieId,
/// The movie's collection's TMDB ID
pub collection: Option<CollectionId>,
/// The list of genre TMDB IDs that the movie is associated with
pub genres: Vec<MovieGenreId>,
}
+1 -1
View File
@@ -11,7 +11,7 @@ pub struct Season {
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GenericSeason {
/// The season's number
pub number: i32,
pub number: u32,
/// The season's name
pub name: String,
/// The season's overview
+2
View File
@@ -21,6 +21,8 @@ pub struct GenericShow {
pub name: 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,
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flix-tmdb"
version = "0.0.1"
version = "0.0.4"
categories = []
description = "Clients and models for fetching data from TMDB"
+2 -2
View File
@@ -1,5 +1,5 @@
# flix
# flix-tmdb
[![Crates Version](https://img.shields.io/crates/v/flix.svg)](https://crates.io/crates/flix)
[![Crates Version](https://img.shields.io/crates/v/flix-tmdb.svg)](https://crates.io/crates/flix-tmdb)
A library providing 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
+2 -2
View File
@@ -1,7 +1,7 @@
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,
@@ -15,7 +15,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,
+2 -2
View File
@@ -1,10 +1,10 @@
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,
pub episode_number: u32,
/// The episode's name
pub name: String,
/// The episode's overview
+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,
+6 -2
View File
@@ -18,8 +18,11 @@ pub enum Collection {}
pub enum Movie {}
pub enum Show {}
type Inner = i32;
/// The inner type of TmdbId
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
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(transparent)]
#[repr(transparent)]
@@ -30,7 +33,8 @@ pub struct TmdbId<T> {
}
impl<T> TmdbId<T> {
pub fn inner(&self) -> Inner {
/// Extract the inner value
pub fn inner(self) -> Inner {
self.inner
}
}
+1
View File
@@ -15,3 +15,4 @@ pub use serde::*;
pub use show::*;
pub use id::{CollectionId, MovieGenreId, MovieId, ShowGenreId, ShowId};
pub use id::{Inner as TmdbIdInner, TmdbId};
+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")]
+2 -2
View File
@@ -3,10 +3,10 @@ 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,
pub season_number: u32,
/// The season's name
pub name: String,
/// The season's overview
+3 -3
View File
@@ -3,7 +3,7 @@ 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,
@@ -18,13 +18,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")]