Model updates, bugfixes, and a new muxing cli tool

This commit is contained in:
2026-05-29 22:26:22 -06:00
parent cf4327389a
commit b6ad592951
32 changed files with 2246 additions and 453 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flix-cli"
version = "0.0.18"
version = "0.0.19"
license-file.workspace = true
description = "CLI for interacting with a flix database"
+1
View File
@@ -5,6 +5,7 @@
CLI for interacting with a flix database
## Commands
```sh
cargo run -- init
cargo run -- add tmdb movie <id>
+6 -1
View File
@@ -10,7 +10,12 @@ pub mod tmdb;
#[command(version, about, long_about = None)]
pub struct Cli {
/// Use a custom config file
#[arg(short, long, value_name = "FILE", default_value = "~/.flix")]
#[arg(
short,
long,
value_name = "FILE",
default_value = "~/.config/flix/config.toml"
)]
config: PathBuf,
/// Use a custom cache file
+3 -5
View File
@@ -30,11 +30,9 @@ async fn main() -> Result<()> {
let database_path = cli.database_path()?;
let client = Client::new(
tmdb::Config::new(config.tmdb().bearer_token().to_owned()),
Rc::new(RedbCache::new(cli.cache_path())?),
CachePolicy::Full,
);
let config = tmdb::Config::new(config.tmdb().bearer_token().to_owned());
let cache = Rc::new(RedbCache::new(cli.cache_path())?);
let client = Client::new(config, cache, CachePolicy::Full);
if cli.trace {
tracing_subscriber::fmt()
+6 -12
View File
@@ -48,12 +48,12 @@ pub async fn add(
})
.await;
let flix_id = match result {
Ok(id) => id,
match result {
Ok(_) => {}
Err(TransactionError::Connection(err)) => Err(err)?,
Err(TransactionError::Transaction(err)) => Err(err)?,
};
println!("Created Collection: {} [{}]", title, flix_id.into_raw());
println!("Created Collection: {}", title);
Ok(())
}
@@ -93,18 +93,12 @@ pub async fn add(
})
.await;
let (flix_show, season_number, episode_number) = match result {
Ok(id) => id,
match result {
Ok(_) => {}
Err(TransactionError::Connection(err)) => Err(err)?,
Err(TransactionError::Transaction(err)) => Err(err)?,
};
println!(
"Created Episode: {} [{} S{} E{}]",
title,
flix_show.into_raw(),
season_number,
episode_number
);
println!("Created Episode: {}", title);
Ok(())
}
+40 -42
View File
@@ -83,12 +83,12 @@ pub async fn add(
})
.await;
let flix_id = match result {
Ok(id) => id,
match result {
Ok(_) => {}
Err(TransactionError::Connection(err)) => Err(err)?,
Err(TransactionError::Transaction(err)) => Err(err)?,
};
println!("Created Collection: {} [{}]", title, flix_id.into_raw());
println!("Created Collection: {}", title);
Ok(())
}
@@ -151,17 +151,12 @@ pub async fn add(
})
.await;
let flix_id = match result {
Ok(id) => id,
match result {
Ok(_) => {}
Err(TransactionError::Connection(err)) => Err(err)?,
Err(TransactionError::Transaction(err)) => Err(err)?,
};
println!(
"Created Movie: {} ({}) [{}]",
title,
year,
flix_id.into_raw(),
);
println!("Created Movie: {} ({})", title, year);
Ok(())
}
@@ -215,18 +210,22 @@ pub async fn add(
let mut season_episodes = Vec::new();
for episode in 1..=number_of_episodes {
let episode = EpisodeNumber::new(episode);
let Ok(episode) = client
let episode = match client
.episodes()
.get_details(id, season.season_number, episode, None)
.await
else {
eprintln!(
"skipping episode ({}, {}, {})",
id.into_raw(),
season.season_number,
episode
);
break;
{
Ok(value) => value,
Err(err) => {
eprintln!(
"skipping episode ({}, {}, {}) - {}",
id.into_raw(),
season.season_number,
episode,
err
);
break;
}
};
season_episodes.push(episode);
}
@@ -329,17 +328,12 @@ pub async fn add(
})
.await;
let flix_id = match result {
Ok(id) => id,
match result {
Ok(_) => {}
Err(TransactionError::Connection(err)) => Err(err)?,
Err(TransactionError::Transaction(err)) => Err(err)?,
};
println!(
"Created Show: {} ({}) [{}]",
title,
year,
flix_id.into_raw()
);
println!("Created Show: {} ({})", title, year);
Ok(())
}
@@ -380,18 +374,22 @@ pub async fn add(
for episode in 1..=number_of_episodes {
let episode = EpisodeNumber::new(episode);
let Ok(episode) = client
let episode = match client
.episodes()
.get_details(id, season.season_number, episode, None)
.await
else {
eprintln!(
"skipping episode ({}, {}, {})",
id.into_raw(),
season.season_number,
episode
);
break;
{
Ok(value) => value,
Err(err) => {
eprintln!(
"skipping episode ({}, {}, {}) - {}",
id.into_raw(),
season.season_number,
episode,
err
);
break;
}
};
episodes.push(episode);
}
@@ -451,7 +449,7 @@ pub async fn add(
.await;
match result {
Ok(_) => (),
Ok(_) => {}
Err(TransactionError::Connection(err)) => Err(err)?,
Err(TransactionError::Transaction(err)) => Err(err)?,
};
@@ -541,7 +539,7 @@ pub async fn add(
.await;
match result {
Ok(_) => (),
Ok(_) => {}
Err(TransactionError::Connection(err)) => Err(err)?,
Err(TransactionError::Transaction(err)) => Err(err)?,
};
@@ -637,7 +635,7 @@ pub async fn update(client: Client, db: &DatabaseConnection, command: Command) -
// Err(TransactionError::Connection(err)) => Err(err)?,
// Err(TransactionError::Transaction(err)) => Err(err)?,
// };
// println!("Created Collection: {} [{}]", title, flix_id.into_raw());
// println!("Created Collection: {}", title, flix_id.into_raw());
// Ok(())
// }
@@ -706,7 +704,7 @@ pub async fn update(client: Client, db: &DatabaseConnection, command: Command) -
// Err(TransactionError::Transaction(err)) => Err(err)?,
// };
// println!(
// "Created Movie: {} ({}) [{}]",
// "Created Movie: {} ({})",
// title,
// year,
// flix_id.into_raw(),
@@ -884,7 +882,7 @@ pub async fn update(client: Client, db: &DatabaseConnection, command: Command) -
// Err(TransactionError::Transaction(err)) => Err(err)?,
// };
// println!(
// "Created Show: {} ({}) [{}]",
// "Created Show: {} ({})",
// title,
// year,
// flix_id.into_raw()