You've already forked flix
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
62e933448c
|
|||
|
492f054e23
|
|||
|
343978e3f2
|
|||
|
45b0a5e601
|
Generated
+3
-3
@@ -214,7 +214,7 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flix"
|
name = "flix"
|
||||||
version = "0.0.1"
|
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.1"
|
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.1"
|
version = "0.0.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
|||||||
+2
-2
@@ -34,8 +34,8 @@ overflow-checks = true
|
|||||||
strip = "debuginfo"
|
strip = "debuginfo"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
flix = { path = "crates/flix", 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.1", 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,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix-cli"
|
name = "flix-cli"
|
||||||
version = "0.0.1"
|
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"
|
||||||
|
|||||||
@@ -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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -46,11 +34,11 @@ impl TmdbObject {
|
|||||||
movie: GenericMovie {
|
movie: GenericMovie {
|
||||||
title: tmdb.title,
|
title: tmdb.title,
|
||||||
overview: tmdb.overview,
|
overview: tmdb.overview,
|
||||||
|
genres: tmdb.genres.iter().cloned().map(|g| g.name).collect(),
|
||||||
release_date: tmdb.release_date,
|
release_date: tmdb.release_date,
|
||||||
},
|
},
|
||||||
tmdb: Some(TmdbMovie {
|
tmdb: Some(TmdbMovie {
|
||||||
id: tmdb.id,
|
id: tmdb.id,
|
||||||
collection: tmdb.collection.map(|c| c.id),
|
|
||||||
genres: tmdb.genres.iter().map(|g| g.id).collect(),
|
genres: tmdb.genres.iter().map(|g| g.id).collect(),
|
||||||
}),
|
}),
|
||||||
})?,
|
})?,
|
||||||
@@ -58,6 +46,7 @@ impl TmdbObject {
|
|||||||
show: GenericShow {
|
show: GenericShow {
|
||||||
name: tmdb.name,
|
name: tmdb.name,
|
||||||
overview: tmdb.overview,
|
overview: tmdb.overview,
|
||||||
|
genres: tmdb.genres.iter().cloned().map(|g| g.name).collect(),
|
||||||
air_date: tmdb.first_air_date,
|
air_date: tmdb.first_air_date,
|
||||||
},
|
},
|
||||||
tmdb: Some(TmdbShow {
|
tmdb: Some(TmdbShow {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix"
|
name = "flix"
|
||||||
version = "0.0.1"
|
version = "0.0.4"
|
||||||
|
|
||||||
categories = []
|
categories = []
|
||||||
description = "Types for storing persistent data about media"
|
description = "Types for storing persistent data about media"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub struct Episode {
|
|||||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct GenericEpisode {
|
pub struct GenericEpisode {
|
||||||
/// The episode's number
|
/// The episode's number
|
||||||
pub number: i32,
|
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
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#[cfg(feature = "tmdb")]
|
#[cfg(feature = "tmdb")]
|
||||||
use flix_tmdb::model::{CollectionId, MovieGenreId, MovieId};
|
use flix_tmdb::model::{MovieGenreId, MovieId};
|
||||||
|
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
|
|
||||||
@@ -21,6 +21,8 @@ pub struct GenericMovie {
|
|||||||
pub title: String,
|
pub title: String,
|
||||||
/// The movie's overview
|
/// The movie's overview
|
||||||
pub overview: String,
|
pub overview: String,
|
||||||
|
/// The movie's genres
|
||||||
|
pub genres: Vec<String>,
|
||||||
/// The movie's release date
|
/// The movie's release date
|
||||||
pub release_date: NaiveDate,
|
pub release_date: NaiveDate,
|
||||||
}
|
}
|
||||||
@@ -31,8 +33,6 @@ pub struct GenericMovie {
|
|||||||
pub struct TmdbMovie {
|
pub struct TmdbMovie {
|
||||||
/// The movie's TMDB ID
|
/// The movie's TMDB ID
|
||||||
pub id: MovieId,
|
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
|
/// The list of genre TMDB IDs that the movie is associated with
|
||||||
pub genres: Vec<MovieGenreId>,
|
pub genres: Vec<MovieGenreId>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub struct Season {
|
|||||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct GenericSeason {
|
pub struct GenericSeason {
|
||||||
/// The season's number
|
/// The season's number
|
||||||
pub number: i32,
|
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
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ pub struct GenericShow {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
/// The show's overview
|
/// The show's overview
|
||||||
pub overview: String,
|
pub overview: String,
|
||||||
|
/// The show's genres
|
||||||
|
pub genres: Vec<String>,
|
||||||
/// The show's air date
|
/// The show's air date
|
||||||
pub air_date: NaiveDate,
|
pub air_date: NaiveDate,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix-tmdb"
|
name = "flix-tmdb"
|
||||||
version = "0.0.1"
|
version = "0.0.4"
|
||||||
|
|
||||||
categories = []
|
categories = []
|
||||||
description = "Clients and models for fetching data from TMDB"
|
description = "Clients and models for fetching data from TMDB"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# flix
|
# flix-tmdb
|
||||||
|
|
||||||
[](https://crates.io/crates/flix)
|
[](https://crates.io/crates/flix-tmdb)
|
||||||
|
|
||||||
A library providing clients and models for fetching data from TMDB
|
A library providing clients and models for fetching data from TMDB
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,7 +1,7 @@
|
|||||||
use super::{CollectionId, MovieId};
|
use super::{CollectionId, MovieId};
|
||||||
|
|
||||||
/// A deserialized Collection from the TMDB API
|
/// A deserialized Collection from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Deserialize)]
|
||||||
pub struct Collection {
|
pub struct Collection {
|
||||||
/// The collection's TMDB ID
|
/// The collection's TMDB ID
|
||||||
pub id: CollectionId,
|
pub id: CollectionId,
|
||||||
@@ -15,7 +15,7 @@ pub struct Collection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A deserialized collection item from the TMDB API
|
/// A deserialized collection item from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Deserialize)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
/// The movie's TMDB ID
|
/// The movie's TMDB ID
|
||||||
pub id: MovieId,
|
pub id: MovieId,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
|
|
||||||
/// A deserialized Episode from the TMDB API
|
/// A deserialized Episode from the TMDB API
|
||||||
#[derive(Debug, 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,7 +1,7 @@
|
|||||||
use super::id::{MovieGenreId, ShowGenreId};
|
use super::id::{MovieGenreId, ShowGenreId};
|
||||||
|
|
||||||
/// A deserialized movie Genre from the TMDB API
|
/// A deserialized movie Genre from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Deserialize)]
|
||||||
pub struct MovieGenre {
|
pub struct MovieGenre {
|
||||||
/// The genre's TMDB ID
|
/// The genre's TMDB ID
|
||||||
pub id: MovieGenreId,
|
pub id: MovieGenreId,
|
||||||
@@ -10,7 +10,7 @@ pub struct MovieGenre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A deserialized show Genre from the TMDB API
|
/// A deserialized show Genre from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Deserialize)]
|
||||||
pub struct ShowGenre {
|
pub struct ShowGenre {
|
||||||
/// The genre's TMDB ID
|
/// The genre's TMDB ID
|
||||||
pub id: ShowGenreId,
|
pub id: ShowGenreId,
|
||||||
|
|||||||
@@ -18,8 +18,11 @@ pub enum Collection {}
|
|||||||
pub enum Movie {}
|
pub enum Movie {}
|
||||||
pub enum Show {}
|
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)]
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
@@ -30,7 +33,8 @@ pub struct TmdbId<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T> TmdbId<T> {
|
impl<T> TmdbId<T> {
|
||||||
pub fn inner(&self) -> Inner {
|
/// Extract the inner value
|
||||||
|
pub fn inner(self) -> Inner {
|
||||||
self.inner
|
self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ pub use serde::*;
|
|||||||
pub use show::*;
|
pub use show::*;
|
||||||
|
|
||||||
pub use id::{CollectionId, MovieGenreId, MovieId, ShowGenreId, ShowId};
|
pub use id::{CollectionId, MovieGenreId, MovieId, ShowGenreId, ShowId};
|
||||||
|
pub use id::{Inner as TmdbIdInner, TmdbId};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use chrono::NaiveDate;
|
|||||||
use super::{CollectionId, MovieGenre, MovieId};
|
use super::{CollectionId, MovieGenre, MovieId};
|
||||||
|
|
||||||
/// A deserialized Movie from the TMDB API
|
/// A deserialized Movie from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Deserialize)]
|
||||||
pub struct Movie {
|
pub struct Movie {
|
||||||
/// The movie's TMDB ID
|
/// The movie's TMDB ID
|
||||||
pub id: MovieId,
|
pub id: MovieId,
|
||||||
@@ -23,14 +23,14 @@ pub struct Movie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A deserialized movie's collection from the TMDB API
|
/// A deserialized movie's collection from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Deserialize)]
|
||||||
pub struct InCollection {
|
pub struct InCollection {
|
||||||
/// The collection's TMDB ID
|
/// The collection's TMDB ID
|
||||||
pub id: CollectionId,
|
pub id: CollectionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A deserialized movie status from the TMDB API
|
/// A deserialized movie status from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, Copy, serde::Deserialize)]
|
||||||
pub enum MovieStatus {
|
pub enum MovieStatus {
|
||||||
/// The movie was cancelled
|
/// The movie was cancelled
|
||||||
#[serde(rename = "Canceled")]
|
#[serde(rename = "Canceled")]
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ use chrono::NaiveDate;
|
|||||||
use super::Episode;
|
use super::Episode;
|
||||||
|
|
||||||
/// A deserialized Season from the TMDB API
|
/// A deserialized Season from the TMDB API
|
||||||
#[derive(Debug, 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
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use chrono::NaiveDate;
|
|||||||
use super::{ShowGenre, ShowId};
|
use super::{ShowGenre, ShowId};
|
||||||
|
|
||||||
/// A deserialized Show from the TMDB API
|
/// A deserialized Show from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Deserialize)]
|
||||||
pub struct Show {
|
pub struct Show {
|
||||||
/// The show's TMDB ID
|
/// The show's TMDB ID
|
||||||
pub id: ShowId,
|
pub id: ShowId,
|
||||||
@@ -18,13 +18,13 @@ 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A deserialized show Status from the TMDB API
|
/// A deserialized show Status from the TMDB API
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, Clone, Copy, serde::Deserialize)]
|
||||||
pub enum ShowStatus {
|
pub enum ShowStatus {
|
||||||
/// The show is returning
|
/// The show is returning
|
||||||
#[serde(rename = "Returning Series")]
|
#[serde(rename = "Returning Series")]
|
||||||
|
|||||||
Reference in New Issue
Block a user