You've already forked flix
Migrate to Zed and add proper newtypes
This commit is contained in:
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"vadimcn.vscode-lldb",
|
||||
"barbosshack.crates-io",
|
||||
"usernamehw.errorlens",
|
||||
"tamasfe.even-better-toml",
|
||||
"rust-lang.rust-analyzer",
|
||||
]
|
||||
}
|
||||
Vendored
-33
@@ -1,33 +0,0 @@
|
||||
{
|
||||
// VSCode
|
||||
"editor.detectIndentation": false,
|
||||
"editor.insertSpaces": false,
|
||||
"editor.tabSize": 4,
|
||||
"files.exclude": {
|
||||
"**/target": true,
|
||||
"**/Cargo.lock": true,
|
||||
},
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.watcherExclude": {
|
||||
"**/.git/**": true,
|
||||
"**/target/**": true,
|
||||
},
|
||||
// Extensions
|
||||
"crates.listPreReleases": true,
|
||||
"evenBetterToml.formatter.alignComments": true,
|
||||
"evenBetterToml.formatter.alignEntries": false,
|
||||
"evenBetterToml.formatter.allowedBlankLines": 1,
|
||||
"evenBetterToml.formatter.arrayAutoExpand": true,
|
||||
"evenBetterToml.formatter.arrayTrailingComma": true,
|
||||
"evenBetterToml.formatter.columnWidth": 80,
|
||||
"evenBetterToml.formatter.reorderKeys": true,
|
||||
"evenBetterToml.formatter.trailingNewline": true,
|
||||
"rust-analyzer.imports.granularity.enforce": true,
|
||||
"rust-analyzer.imports.granularity.group": "module",
|
||||
"rust-analyzer.imports.group.enable": true,
|
||||
"rust-analyzer.imports.merge.glob": false,
|
||||
"rust-analyzer.imports.preferNoStd": true,
|
||||
"rust-analyzer.showUnlinkedFileNotification": false,
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"project_name": null,
|
||||
|
||||
"auto_install_extensions": {
|
||||
"tombi": true,
|
||||
"cargo-appraiser": true,
|
||||
},
|
||||
|
||||
"languages": {
|
||||
"TOML": {
|
||||
"format_on_save": "on",
|
||||
"formatter": { "language_server": { "name": "tombi" } },
|
||||
},
|
||||
},
|
||||
|
||||
"lsp": {
|
||||
"rust-analyzer": {
|
||||
"initialization_options": {
|
||||
"imports": {
|
||||
"granularity": { "enforce": true, "group": "module" },
|
||||
"group": { "enable": true },
|
||||
"merge": { "glob": false },
|
||||
"preferNoStd": true,
|
||||
},
|
||||
"server": {
|
||||
"extraEnv": {
|
||||
"RUSTUP_TOOLCHAIN": "stable",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Generated
+536
-196
File diff suppressed because it is too large
Load Diff
+41
-45
@@ -1,18 +1,41 @@
|
||||
[workspace]
|
||||
members = ["crates/*"]
|
||||
resolver = "2"
|
||||
members = ["crates/*"]
|
||||
|
||||
[workspace.package]
|
||||
authors = []
|
||||
edition = "2024"
|
||||
license-file = "LICENSE.md"
|
||||
rust-version = "1.85.0"
|
||||
license-file = "LICENSE.md"
|
||||
|
||||
[workspace.lints.rust]
|
||||
arithmetic_overflow = "forbid"
|
||||
missing_docs = "forbid"
|
||||
unsafe_code = "forbid"
|
||||
unused_doc_comments = "forbid"
|
||||
[workspace.dependencies]
|
||||
anyhow = { version = "^1", default-features = false }
|
||||
async-stream = { version = "^0.3", default-features = false }
|
||||
chrono = { version = "^0.4", default-features = false }
|
||||
clap = { version = "^4", default-features = false }
|
||||
flix = { path = "crates/flix", version = "=0.0.16", default-features = false }
|
||||
flix-cli = { path = "crates/cli", version = "=0.0.16", default-features = false }
|
||||
flix-db = { path = "crates/db", version = "=0.0.16", default-features = false }
|
||||
flix-fs = { path = "crates/fs", version = "=0.0.16", default-features = false }
|
||||
flix-model = { path = "crates/model", version = "=0.0.16", default-features = false }
|
||||
flix-tmdb = { path = "crates/tmdb", version = "=0.0.16", default-features = false }
|
||||
futures = { version = "^0.3", default-features = false }
|
||||
governor = { version = "^0.10", default-features = false }
|
||||
nonzero_ext = { version = "^0.3", default-features = false }
|
||||
regex = { version = "^1", default-features = false }
|
||||
reqwest = { version = "^0.13", default-features = false }
|
||||
sea-orm = { version = "2.0.0-rc.27", default-features = false }
|
||||
sea-orm-migration = { version = "2.0.0-rc.27", default-features = false }
|
||||
seamantic = { version = "^0.0.11", default-features = false }
|
||||
serde = { version = "^1", default-features = false }
|
||||
serde_test = { version = "^1", default-features = false }
|
||||
thiserror = { version = "^2", default-features = false }
|
||||
tokio = { version = "^1", default-features = false }
|
||||
tokio-stream = { version = "^0.1", default-features = false }
|
||||
toml = { version = "^0.9", default-features = false }
|
||||
tracing = { version = "^0.1", default-features = false }
|
||||
tracing-subscriber = { version = "^0.3", default-features = false }
|
||||
url = { version = "^2", default-features = false }
|
||||
url-macro = { version = "^0.2", default-features = false }
|
||||
|
||||
[workspace.lints.clippy]
|
||||
arithmetic_side_effects = "forbid"
|
||||
@@ -24,45 +47,18 @@ indexing_slicing = "forbid"
|
||||
integer_division = "forbid"
|
||||
integer_division_remainder_used = "forbid"
|
||||
transmute_undefined_repr = "forbid"
|
||||
unchecked_duration_subtraction = "forbid"
|
||||
unchecked_time_subtraction = "forbid"
|
||||
unwrap_used = "forbid"
|
||||
|
||||
[workspace.lints.rust]
|
||||
arithmetic_overflow = "forbid"
|
||||
missing_docs = "forbid"
|
||||
unsafe_code = "forbid"
|
||||
unused_doc_comments = "forbid"
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
lto = "fat"
|
||||
opt-level = 3
|
||||
overflow-checks = true
|
||||
strip = "debuginfo"
|
||||
|
||||
[workspace.dependencies]
|
||||
flix = { path = "crates/flix", version = "=0.0.15", default-features = false }
|
||||
flix-cli = { path = "crates/cli", version = "=0.0.15", default-features = false }
|
||||
flix-db = { path = "crates/db", version = "=0.0.15", default-features = false }
|
||||
flix-fs = { path = "crates/fs", version = "=0.0.15", default-features = false }
|
||||
flix-model = { path = "crates/model", version = "=0.0.15", default-features = false }
|
||||
flix-tmdb = { path = "crates/tmdb", version = "=0.0.15", default-features = false }
|
||||
|
||||
seamantic = { version = "0.0.10", default-features = false }
|
||||
|
||||
sea-orm = { version = "2.0.0-rc.18", default-features = false }
|
||||
sea-orm-migration = { version = "2.0.0-rc.18", default-features = false }
|
||||
|
||||
anyhow = { version = "^1", default-features = false }
|
||||
async-stream = { version = "^0.3", 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 }
|
||||
governor = { version = "^0.10", default-features = false }
|
||||
nonzero_ext = { version = "^0.3", default-features = false }
|
||||
regex = { version = "^1", default-features = false }
|
||||
reqwest = { version = "^0.12", default-features = false }
|
||||
serde = { version = "^1", default-features = false }
|
||||
serde_test = { version = "^1", default-features = false }
|
||||
thiserror = { version = "^2", default-features = false }
|
||||
tokio = { version = "^1", default-features = false }
|
||||
tokio-stream = { version = "^0.1", default-features = false }
|
||||
toml = { version = "^0.9", default-features = false }
|
||||
tracing = { version = "^0.1", default-features = false }
|
||||
tracing-subscriber = { version = "^0.3", default-features = false }
|
||||
url = { version = "^2", default-features = false }
|
||||
url-macro = { version = "^0.2", default-features = false }
|
||||
overflow-checks = true
|
||||
lto = "fat"
|
||||
codegen-units = 1
|
||||
|
||||
+28
-31
@@ -1,15 +1,12 @@
|
||||
[package]
|
||||
name = "flix-cli"
|
||||
version = "0.0.15"
|
||||
|
||||
categories = ["command-line-utilities"]
|
||||
version = "0.0.16"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "CLI for interacting with a flix database"
|
||||
repository = "https://github.com/QuantumShade/flix"
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license-file.workspace = true
|
||||
rust-version.workspace = true
|
||||
categories = ["command-line-utilities"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@@ -20,9 +17,26 @@ doc = false
|
||||
name = "flix"
|
||||
path = "src/main.rs"
|
||||
|
||||
[lints.rust]
|
||||
arithmetic_overflow = "forbid"
|
||||
unsafe_code = "forbid"
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
chrono = { workspace = true, features = ["now"] }
|
||||
clap = { workspace = true, features = [
|
||||
"color",
|
||||
"derive",
|
||||
"error-context",
|
||||
"help",
|
||||
"std",
|
||||
"suggestions",
|
||||
"usage",
|
||||
] }
|
||||
flix = { workspace = true, features = ["tmdb"] }
|
||||
futures = { workspace = true }
|
||||
sea-orm = { workspace = true, features = ["debug-print", "runtime-tokio"] }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
tokio = { workspace = true, features = ["fs", "macros", "rt"] }
|
||||
toml = { workspace = true, features = ["parse", "serde"] }
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
|
||||
[lints.clippy]
|
||||
arithmetic_side_effects = "deny"
|
||||
@@ -34,26 +48,9 @@ indexing_slicing = "deny"
|
||||
integer_division = "deny"
|
||||
integer_division_remainder_used = "deny"
|
||||
transmute_undefined_repr = "deny"
|
||||
unchecked_duration_subtraction = "deny"
|
||||
unchecked_time_subtraction = "deny"
|
||||
unwrap_used = "deny"
|
||||
|
||||
[dependencies]
|
||||
flix = { workspace = true, features = ["tmdb"] }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
chrono = { workspace = true, features = ["now"] }
|
||||
clap = { workspace = true, features = [
|
||||
"derive",
|
||||
"color",
|
||||
"error-context",
|
||||
"help",
|
||||
"suggestions",
|
||||
"usage",
|
||||
] }
|
||||
futures = { workspace = true }
|
||||
sea-orm = { workspace = true, features = ["runtime-tokio", "debug-print"] }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
tokio = { workspace = true, features = ["rt", "fs", "macros"] }
|
||||
toml = { workspace = true, features = ["parse", "serde"] }
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
[lints.rust]
|
||||
arithmetic_overflow = "forbid"
|
||||
unsafe_code = "forbid"
|
||||
|
||||
@@ -150,13 +150,20 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
||||
let year = show.first_air_date.year();
|
||||
|
||||
for season in 1..=show.number_of_seasons {
|
||||
let season = client
|
||||
let season = SeasonNumber::new(season);
|
||||
let season = match client
|
||||
.seasons()
|
||||
.get_details(id, season, None)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!("seasons().get_details({}, {})", id.into_raw(), season)
|
||||
})?;
|
||||
}) {
|
||||
Ok(season) => season,
|
||||
Err(err) => {
|
||||
eprintln!("{err:?}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if season.air_date > Utc::now().naive_utc().date() {
|
||||
eprintln!(
|
||||
"skipping season ({}, {})",
|
||||
@@ -166,7 +173,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
||||
break;
|
||||
}
|
||||
|
||||
let Ok(number_of_episodes) = EpisodeNumber::try_from(season.episodes.len()) else {
|
||||
let Ok(number_of_episodes) = u32::try_from(season.episodes.len()) else {
|
||||
bail!(
|
||||
"could not convert {} to an EpisodeNumber",
|
||||
season.episodes.len()
|
||||
@@ -175,6 +182,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
||||
|
||||
let mut season_episodes = Vec::new();
|
||||
for episode in 1..=number_of_episodes {
|
||||
let episode = EpisodeNumber::new(episode);
|
||||
let Ok(episode) = client
|
||||
.episodes()
|
||||
.get_details(id, season.season_number, episode, None)
|
||||
@@ -314,7 +322,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
||||
})?;
|
||||
let mut episodes = Vec::new();
|
||||
|
||||
let Ok(number_of_episodes) = EpisodeNumber::try_from(season.episodes.len()) else {
|
||||
let Ok(number_of_episodes) = u32::try_from(season.episodes.len()) else {
|
||||
bail!(
|
||||
"could not convert {} to an EpisodeNumber",
|
||||
season.episodes.len()
|
||||
@@ -322,6 +330,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
||||
};
|
||||
|
||||
for episode in 1..=number_of_episodes {
|
||||
let episode = EpisodeNumber::new(episode);
|
||||
let Ok(episode) = client
|
||||
.episodes()
|
||||
.get_details(id, season.season_number, episode, None)
|
||||
|
||||
+15
-21
@@ -1,45 +1,39 @@
|
||||
[package]
|
||||
name = "flix-db"
|
||||
version = "0.0.15"
|
||||
|
||||
categories = []
|
||||
version = "0.0.16"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "Types for storing persistent data about media"
|
||||
repository = "https://github.com/QuantumShade/flix"
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license-file.workspace = true
|
||||
rust-version.workspace = true
|
||||
categories = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
tmdb = ["dep:flix-tmdb"]
|
||||
|
||||
[dependencies]
|
||||
flix-model = { workspace = true }
|
||||
|
||||
flix-tmdb = { workspace = true, optional = true, features = ["sea-orm"] }
|
||||
|
||||
seamantic = { workspace = true, features = ["sqlite"] }
|
||||
|
||||
chrono = { workspace = true }
|
||||
flix-model = { workspace = true }
|
||||
flix-tmdb = { workspace = true, features = ["sea-orm"], optional = true }
|
||||
sea-orm = { workspace = true, features = [
|
||||
"entity-registry",
|
||||
"schema-sync",
|
||||
"with-chrono",
|
||||
] }
|
||||
sea-orm-migration = { workspace = true }
|
||||
seamantic = { workspace = true, features = ["sqlite"] }
|
||||
|
||||
[dev-dependencies]
|
||||
sea-orm-migration = { workspace = true, features = ["runtime-tokio-rustls"] }
|
||||
tokio = { version = "^1", default-features = false, features = [
|
||||
"rt",
|
||||
"macros",
|
||||
"rt",
|
||||
] }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
tmdb = ["dep:flix-tmdb"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -384,7 +384,7 @@ pub mod test {
|
||||
$crate::entity::info::test::make_info_season!($db, $show, $season);
|
||||
$crate::entity::content::seasons::ActiveModel {
|
||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||
season_number: Set($season),
|
||||
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||
slug: Set(concat!("SS ", $show, $season).to_string()),
|
||||
library_id: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||
directory: Set(::std::path::PathBuf::new().into()),
|
||||
@@ -408,8 +408,8 @@ pub mod test {
|
||||
$crate::entity::info::test::make_info_episode!($db, $show, $season, $episode);
|
||||
$crate::entity::content::episodes::ActiveModel {
|
||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||
season_number: Set($season),
|
||||
episode_number: Set($episode),
|
||||
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||
episode_number: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||
count: Set($count),
|
||||
slug: Set(concat!("SSE ", $show, $season, $episode).to_string()),
|
||||
library_id: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||
@@ -690,7 +690,7 @@ mod tests {
|
||||
.expect("insert");
|
||||
|
||||
assert_eq!(model.show_id, ShowId::from_raw($id));
|
||||
assert_eq!(model.season_number, $season);
|
||||
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||
assert_eq!(model.slug, concat!("SS Slug ", $id, ",", $season).to_string());
|
||||
assert_eq!(model.library_id, LibraryId::from_raw($lid));
|
||||
assert_eq!(model.directory, Path::new(concat!("SS Directory ", $id, ",", $season)).to_owned().into());
|
||||
@@ -705,7 +705,7 @@ mod tests {
|
||||
(@insert, $db:expr, $id:literal, $season:literal, $lid:literal $(; $($skip:ident),+)?) => {
|
||||
super::seasons::ActiveModel {
|
||||
show_id: notsettable!(show_id, ShowId::from_raw($id) $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||
slug: notsettable!(slug, concat!("SS Slug ", $id, ",", $season).to_string() $(, $($skip),+)?),
|
||||
library_id: notsettable!(library_id, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||
directory: notsettable!(directory, Path::new(concat!("SS Directory ", $id, ",", $season)).to_owned().into() $(, $($skip),+)?),
|
||||
@@ -745,8 +745,8 @@ mod tests {
|
||||
.expect("insert");
|
||||
|
||||
assert_eq!(model.show_id, ShowId::from_raw($id));
|
||||
assert_eq!(model.season_number, $season);
|
||||
assert_eq!(model.episode_number, $episode);
|
||||
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||
assert_eq!(model.episode_number, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||
assert_eq!(model.slug, concat!("SS Slug ", $id, ",", $season, $episode).to_string());
|
||||
assert_eq!(model.library_id, LibraryId::from_raw($lid));
|
||||
assert_eq!(model.directory, Path::new(concat!("SS Directory ", $id, ",", $season, $episode)).to_owned().into());
|
||||
@@ -762,8 +762,8 @@ mod tests {
|
||||
(@insert, $db:expr, $id:literal, $season:literal, $episode:literal, $lid:literal $(; $($skip:ident),+)?) => {
|
||||
super::episodes::ActiveModel {
|
||||
show_id: notsettable!(show_id, ShowId::from_raw($id) $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
||||
episode_number: notsettable!(episode_number, $episode $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||
episode_number: notsettable!(episode_number, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||
count: notsettable!(count, 0 $(, $($skip),+)?),
|
||||
slug: notsettable!(slug, concat!("SS Slug ", $id, ",", $season, $episode).to_string() $(, $($skip),+)?),
|
||||
library_id: notsettable!(library_id, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||
|
||||
@@ -228,7 +228,7 @@ pub mod test {
|
||||
($db:expr, $show:literal, $season:literal) => {
|
||||
$crate::entity::info::seasons::ActiveModel {
|
||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||
season_number: Set($season),
|
||||
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||
title: Set(::std::string::String::new()),
|
||||
overview: Set(::std::string::String::new()),
|
||||
date: Set(::chrono::NaiveDate::from_yo_opt(1, 1).expect("from_yo_opt")),
|
||||
@@ -244,8 +244,8 @@ pub mod test {
|
||||
($db:expr, $show:literal, $season:literal, $episode:literal) => {
|
||||
$crate::entity::info::episodes::ActiveModel {
|
||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||
season_number: Set($season),
|
||||
episode_number: Set($episode),
|
||||
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||
episode_number: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||
title: Set(::std::string::String::new()),
|
||||
overview: Set(::std::string::String::new()),
|
||||
date: Set(::chrono::NaiveDate::from_yo_opt(1, 1).expect("from_yo_opt")),
|
||||
@@ -422,7 +422,7 @@ mod tests {
|
||||
.expect("insert");
|
||||
|
||||
assert_eq!(model.show_id, ShowId::from_raw($show));
|
||||
assert_eq!(model.season_number, $season);
|
||||
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||
assert_eq!(model.title, concat!("SS Title ", $show, ",", $season));
|
||||
assert_eq!(model.overview, concat!("SS Overview ", $show, ",", $season));
|
||||
assert_eq!(model.date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt"));
|
||||
@@ -439,7 +439,7 @@ mod tests {
|
||||
(@insert, $db:expr, $show:literal, $season:literal $(; $($skip:ident),+)?) => {
|
||||
super::seasons::ActiveModel {
|
||||
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||
title: notsettable!(title, concat!("SS Title ", $show, ",", $season).to_string() $(, $($skip),+)?),
|
||||
overview: notsettable!(overview, concat!("SS Overview ", $show, ",", $season).to_string() $(, $($skip),+)?),
|
||||
date: notsettable!(date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt") $(, $($skip),+)?),
|
||||
@@ -473,8 +473,8 @@ mod tests {
|
||||
.expect("insert");
|
||||
|
||||
assert_eq!(model.show_id, ShowId::from_raw($show));
|
||||
assert_eq!(model.season_number, $season);
|
||||
assert_eq!(model.episode_number, $episode);
|
||||
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||
assert_eq!(model.episode_number, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||
assert_eq!(model.title, concat!("SSE Title ", $show, ",", $season, ",", $episode));
|
||||
assert_eq!(model.overview, concat!("SSE Overview ", $show, ",", $season, ",", $episode));
|
||||
assert_eq!(model.date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt"));
|
||||
@@ -491,8 +491,8 @@ mod tests {
|
||||
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal $(; $($skip:ident),+)?) => {
|
||||
super::episodes::ActiveModel {
|
||||
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
||||
episode_number: notsettable!(episode_number, $episode $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||
episode_number: notsettable!(episode_number, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||
title: notsettable!(title, concat!("SSE Title ", $show, ",", $season, ",", $episode).to_string() $(, $($skip),+)?),
|
||||
overview: notsettable!(overview, concat!("SSE Overview ", $show, ",", $season, ",", $episode).to_string() $(, $($skip),+)?),
|
||||
date: notsettable!(date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt") $(, $($skip),+)?),
|
||||
|
||||
@@ -280,9 +280,9 @@ pub mod test {
|
||||
($db:expr, $show:literal, $season:literal, $flix_show:literal, $flix_season:literal) => {
|
||||
$crate::entity::tmdb::seasons::ActiveModel {
|
||||
tmdb_show: Set(::flix_tmdb::model::id::ShowId::from_raw($show)),
|
||||
tmdb_season: Set($season),
|
||||
tmdb_season: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||
flix_show: Set(::flix_model::id::ShowId::from_raw($flix_show)),
|
||||
flix_season: Set($flix_season),
|
||||
flix_season: Set(::flix_model::numbers::SeasonNumber::new($flix_season)),
|
||||
last_update: Set(::chrono::Utc::now()),
|
||||
}
|
||||
.insert($db)
|
||||
@@ -296,11 +296,11 @@ pub mod test {
|
||||
($db:expr, $show:literal, $season:literal, $episode:literal, $flix_show:literal, $flix_season:literal, $flix_episode:literal) => {
|
||||
$crate::entity::tmdb::episodes::ActiveModel {
|
||||
tmdb_show: Set(::flix_tmdb::model::id::ShowId::from_raw($show)),
|
||||
tmdb_season: Set($season),
|
||||
tmdb_episode: Set($episode),
|
||||
tmdb_season: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||
tmdb_episode: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||
flix_show: Set(::flix_model::id::ShowId::from_raw($flix_show)),
|
||||
flix_season: Set($flix_season),
|
||||
flix_episode: Set($flix_episode),
|
||||
flix_season: Set(::flix_model::numbers::SeasonNumber::new($flix_season)),
|
||||
flix_episode: Set(::flix_model::numbers::EpisodeNumber::new($flix_episode)),
|
||||
last_update: Set(::chrono::Utc::now()),
|
||||
runtime: Set(::core::default::Default::default()),
|
||||
}
|
||||
@@ -514,9 +514,9 @@ mod tests {
|
||||
.expect("insert");
|
||||
|
||||
assert_eq!(model.tmdb_show, TmdbShowId::from_raw($tshow));
|
||||
assert_eq!(model.tmdb_season, $tseason);
|
||||
assert_eq!(model.tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason));
|
||||
assert_eq!(model.flix_show, ShowId::from_raw($show));
|
||||
assert_eq!(model.flix_season, $season);
|
||||
assert_eq!(model.flix_season, ::flix_model::numbers::SeasonNumber::new($season));
|
||||
assert_eq!(model.last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
||||
};
|
||||
($db:expr, $show:literal, $season:literal, $tshow:literal, $tseason:literal, $error:ident $(; $($skip:ident),+)?) => {
|
||||
@@ -531,9 +531,9 @@ mod tests {
|
||||
(@insert, $db:expr, $show:literal, $season:literal, $tshow:literal, $tseason:literal $(; $($skip:ident),+)?) => {
|
||||
super::seasons::ActiveModel {
|
||||
tmdb_show: notsettable!(tmdb_show, TmdbShowId::from_raw($tshow) $(, $($skip),+)?),
|
||||
tmdb_season: notsettable!(tmdb_season, $tseason $(, $($skip),+)?),
|
||||
tmdb_season: notsettable!(tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason) $(, $($skip),+)?),
|
||||
flix_show: notsettable!(flix_show, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||
flix_season: notsettable!(flix_season, $season $(, $($skip),+)?),
|
||||
flix_season: notsettable!(flix_season, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||
last_update: notsettable!(last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
};
|
||||
@@ -569,11 +569,11 @@ mod tests {
|
||||
.expect("insert");
|
||||
|
||||
assert_eq!(model.tmdb_show, TmdbShowId::from_raw($tshow));
|
||||
assert_eq!(model.tmdb_season, $tseason);
|
||||
assert_eq!(model.tmdb_episode, $tepisode);
|
||||
assert_eq!(model.tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason));
|
||||
assert_eq!(model.tmdb_episode, ::flix_model::numbers::EpisodeNumber::new($tepisode));
|
||||
assert_eq!(model.flix_show, ShowId::from_raw($show));
|
||||
assert_eq!(model.flix_season, $season);
|
||||
assert_eq!(model.flix_episode, $episode);
|
||||
assert_eq!(model.flix_season, ::flix_model::numbers::SeasonNumber::new($season));
|
||||
assert_eq!(model.flix_episode, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||
assert_eq!(model.last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
||||
assert_eq!(model.runtime, Duration::from_secs($tshow).into());
|
||||
};
|
||||
@@ -589,11 +589,11 @@ mod tests {
|
||||
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal, $tshow:literal, $tseason:literal, $tepisode:literal $(; $($skip:ident),+)?) => {
|
||||
super::episodes::ActiveModel {
|
||||
tmdb_show: notsettable!(tmdb_show, TmdbShowId::from_raw($tshow) $(, $($skip),+)?),
|
||||
tmdb_season: notsettable!(tmdb_season, $tseason $(, $($skip),+)?),
|
||||
tmdb_episode: notsettable!(tmdb_episode, $tepisode $(, $($skip),+)?),
|
||||
tmdb_season: notsettable!(tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason) $(, $($skip),+)?),
|
||||
tmdb_episode: notsettable!(tmdb_episode, ::flix_model::numbers::EpisodeNumber::new($tepisode) $(, $($skip),+)?),
|
||||
flix_show: notsettable!(flix_show, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||
flix_season: notsettable!(flix_season, $season $(, $($skip),+)?),
|
||||
flix_episode: notsettable!(flix_episode, $episode $(, $($skip),+)?),
|
||||
flix_season: notsettable!(flix_season, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||
flix_episode: notsettable!(flix_episode, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||
last_update: notsettable!(last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
||||
runtime: notsettable!(runtime, Duration::from_secs($tshow).into() $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
|
||||
@@ -224,8 +224,8 @@ pub mod test {
|
||||
($db:expr, $show:literal, $season:literal, $episode:literal, $user:literal) => {
|
||||
$crate::entity::watched::episodes::ActiveModel {
|
||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||
season_number: Set($season),
|
||||
episode_number: Set($episode),
|
||||
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||
episode_number: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||
user_id: Set($user),
|
||||
watched_date: Set(::chrono::Utc::now()),
|
||||
}
|
||||
@@ -326,8 +326,8 @@ mod tests {
|
||||
.expect("insert");
|
||||
|
||||
assert_eq!(model.show_id, ShowId::from_raw($show));
|
||||
assert_eq!(model.season_number, $season);
|
||||
assert_eq!(model.episode_number, $episode);
|
||||
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||
assert_eq!(model.episode_number, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||
assert_eq!(model.user_id, $uid);
|
||||
assert_eq!(model.watched_date, NaiveDate::from_yo_opt($uid, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
||||
};
|
||||
@@ -340,8 +340,8 @@ mod tests {
|
||||
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal, $uid:literal $(; $($skip:ident),+)?) => {
|
||||
super::episodes::ActiveModel {
|
||||
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
||||
episode_number: notsettable!(episode_number, $episode $(, $($skip),+)?),
|
||||
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||
episode_number: notsettable!(episode_number, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||
user_id: notsettable!(user_id, $uid $(, $($skip),+)?),
|
||||
watched_date: notsettable!(watched_date, NaiveDate::from_yo_opt($uid, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
|
||||
+11
-15
@@ -1,22 +1,22 @@
|
||||
[package]
|
||||
name = "flix"
|
||||
version = "0.0.15"
|
||||
|
||||
categories = []
|
||||
version = "0.0.16"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "Mechanisms for interacting with flix media"
|
||||
repository = "https://github.com/QuantumShade/flix"
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license-file.workspace = true
|
||||
rust-version.workspace = true
|
||||
categories = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
[dependencies]
|
||||
flix-db = { workspace = true }
|
||||
flix-fs = { workspace = true, optional = true }
|
||||
flix-model = { workspace = true }
|
||||
flix-tmdb = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
@@ -24,9 +24,5 @@ fs = ["dep:flix-fs"]
|
||||
serde = ["flix-model/serde"]
|
||||
tmdb = ["dep:flix-tmdb", "flix-db/tmdb"]
|
||||
|
||||
[dependencies]
|
||||
flix-db = { workspace = true }
|
||||
flix-model = { workspace = true }
|
||||
|
||||
flix-fs = { workspace = true, optional = true }
|
||||
flix-tmdb = { workspace = true, optional = true }
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
+9
-13
@@ -1,28 +1,24 @@
|
||||
[package]
|
||||
name = "flix-fs"
|
||||
version = "0.0.15"
|
||||
|
||||
categories = []
|
||||
version = "0.0.16"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "Filesystem scanner for flix media"
|
||||
repository = "https://github.com/QuantumShade/flix"
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license-file.workspace = true
|
||||
rust-version.workspace = true
|
||||
categories = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
flix-model = { workspace = true }
|
||||
|
||||
async-stream = { workspace = true }
|
||||
regex = { workspace = true, features = ["std", "perf"] }
|
||||
flix-model = { workspace = true }
|
||||
regex = { workspace = true, features = ["perf", "std"] }
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tokio-stream = { workspace = true, features = ["fs"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
+10
-14
@@ -1,29 +1,25 @@
|
||||
[package]
|
||||
name = "flix-model"
|
||||
version = "0.0.15"
|
||||
|
||||
categories = []
|
||||
version = "0.0.16"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "Core types for flix data"
|
||||
repository = "https://github.com/QuantumShade/flix"
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license-file.workspace = true
|
||||
rust-version.workspace = true
|
||||
categories = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
[dependencies]
|
||||
seamantic = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive", "std"], optional = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
serde = ["dep:serde"]
|
||||
|
||||
[dependencies]
|
||||
seamantic = { workspace = true }
|
||||
|
||||
serde = { workspace = true, optional = true, features = ["std", "derive"] }
|
||||
thiserror = { workspace = true }
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -1,12 +1,76 @@
|
||||
//! This module contains season and episode numbers and related errors
|
||||
|
||||
use core::fmt;
|
||||
use core::ops::RangeInclusive;
|
||||
use core::str::FromStr;
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// Type alias for representing season numbers
|
||||
pub type SeasonNumber = u32;
|
||||
/// Type alias for representing episode numbers
|
||||
pub type EpisodeNumber = u32;
|
||||
use seamantic::sea_orm;
|
||||
|
||||
/// Newtype for representing season numbers
|
||||
#[derive(
|
||||
Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, sea_orm::DeriveValueType,
|
||||
)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||
#[repr(transparent)]
|
||||
pub struct SeasonNumber(u32);
|
||||
|
||||
impl SeasonNumber {
|
||||
/// Create a `SeasonNumber` from an integer
|
||||
pub fn new(value: u32) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SeasonNumber {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SeasonNumber {
|
||||
type Err = <u32 as FromStr>::Err;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
u32::from_str(s).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Newtype for representing episode numbers
|
||||
#[derive(
|
||||
Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, sea_orm::DeriveValueType,
|
||||
)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||
#[repr(transparent)]
|
||||
pub struct EpisodeNumber(u32);
|
||||
|
||||
impl EpisodeNumber {
|
||||
/// Create an `EpisodeNumber` from an integer
|
||||
pub fn new(value: u32) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
/// Get the underlying value
|
||||
pub fn into_inner(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for EpisodeNumber {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for EpisodeNumber {
|
||||
type Err = <u32 as FromStr>::Err;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
u32::from_str(s).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Potential errors when building EpisodeNumbers
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
@@ -37,7 +101,7 @@ impl TryFrom<&[EpisodeNumber]> for EpisodeNumbers {
|
||||
let max = value.iter().copied().max().unwrap_or_default();
|
||||
let len = value.len();
|
||||
|
||||
if usize::try_from(max.saturating_sub(min).saturating_add(1)) != Ok(len) {
|
||||
if usize::try_from(max.0.saturating_sub(min.0).saturating_add(1)) != Ok(len) {
|
||||
return Err(Error::Noncontiguous);
|
||||
}
|
||||
|
||||
@@ -56,7 +120,7 @@ impl EpisodeNumbers {
|
||||
/// Create an [EpisodeNumbers] from a starting number and a count.
|
||||
/// `count` should be zero for single episodes.
|
||||
pub fn new(start: EpisodeNumber, count: u8) -> Self {
|
||||
Self(start..=start.saturating_add(count.into()))
|
||||
Self(start..=EpisodeNumber(start.0.saturating_add(count.into())))
|
||||
}
|
||||
|
||||
/// Get the range of episodes
|
||||
|
||||
+15
-20
@@ -1,40 +1,35 @@
|
||||
[package]
|
||||
name = "flix-tmdb"
|
||||
version = "0.0.15"
|
||||
|
||||
categories = []
|
||||
version = "0.0.16"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "Clients and models for fetching data from TMDB"
|
||||
repository = "https://github.com/QuantumShade/flix"
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license-file.workspace = true
|
||||
rust-version.workspace = true
|
||||
categories = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
sea-orm = ["dep:sea-orm"]
|
||||
|
||||
[dependencies]
|
||||
flix-model = { workspace = true }
|
||||
|
||||
chrono = { workspace = true, features = ["serde"] }
|
||||
governor = { workspace = true, features = ["std", "jitter"] }
|
||||
flix-model = { workspace = true, features = ["serde"] }
|
||||
governor = { workspace = true, features = ["jitter", "std"] }
|
||||
nonzero_ext = { workspace = true }
|
||||
reqwest = { workspace = true, features = ["json", "rustls-tls"] }
|
||||
reqwest = { workspace = true, features = ["json", "query", "rustls"] }
|
||||
sea-orm = { workspace = true, optional = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
thiserror = { workspace = true }
|
||||
url = { workspace = true }
|
||||
url-macro = { workspace = true }
|
||||
|
||||
sea-orm = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_test = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
sea-orm = ["dep:sea-orm"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
toml-version = "v1.0.0"
|
||||
|
||||
[format.rules]
|
||||
indent-style = "tab"
|
||||
indent-width = 4
|
||||
Reference in New Issue
Block a user