diff options
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | common/src/lib.rs | 4 | ||||
-rw-r--r-- | import/src/lib.rs | 3 | ||||
-rw-r--r-- | tool/Cargo.toml | 2 | ||||
-rw-r--r-- | tool/src/main.rs | 87 |
5 files changed, 30 insertions, 68 deletions
@@ -1483,8 +1483,6 @@ dependencies = [ "jellybase", "jellyclient", "jellycommon", - "jellymatroska", - "jellyremuxer", "log", "rand", "reqwest", diff --git a/common/src/lib.rs b/common/src/lib.rs index ce83bd4..e348d21 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -69,7 +69,9 @@ pub enum ImportSource { }, Media { location: AssetLocation, - // TODO ignore options + ignore_attachments: bool, + ignore_metadata: bool, + // TODO all ignore options }, Federated { host: String, diff --git a/import/src/lib.rs b/import/src/lib.rs index 9ed786a..6639789 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -180,7 +180,8 @@ async fn process_source( match s { ImportSource::Override(n) => insert_node(&id, n)?, ImportSource::Tmdb(_) => todo!(), - ImportSource::Media { location } => { + ImportSource::Media { location, .. } => { + // TODO use ignore options let media_path = location.path(); let metadata = spawn_blocking(move || { diff --git a/tool/Cargo.toml b/tool/Cargo.toml index 9ad1af4..9f72df5 100644 --- a/tool/Cargo.toml +++ b/tool/Cargo.toml @@ -7,8 +7,6 @@ edition = "2021" jellycommon = { path = "../common" } jellybase = { path = "../base" } jellyclient = { path = "../client" } -jellymatroska = { path = "../matroska" } -jellyremuxer = { path = "../remuxer" } log = { workspace = true } env_logger = "0.10.1" diff --git a/tool/src/main.rs b/tool/src/main.rs index 6384822..7b58125 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -7,6 +7,7 @@ pub mod migrate; +use anyhow::anyhow; use base64::Engine; use clap::{Parser, Subcommand, ValueEnum}; use jellyclient::{Instance, LoginDetails}; @@ -18,8 +19,9 @@ use std::{fmt::Debug, fs::File, io::Write, path::PathBuf}; #[derive(Parser)] struct Args { - #[arg(short = 'N', long)] - dry: bool, + /// Path to global jellything config + #[arg(short = 'C', long)] + config: Option<PathBuf>, #[clap(subcommand)] action: Action, } @@ -35,55 +37,12 @@ enum Action { #[arg(short, long)] hostname: String, }, - // /// Imports a movie, video or series given media and metadata sources - // New { - // /// Relative path to the node's parent(!). - // path: PathBuf, - // /// Search the node by title on TMDB - // #[arg(short = 't', long)] - // tmdb_search: Option<String>, - // /// Search the node by id on TMDB - // #[arg(short = 'T', long)] - // tmdb_id: Option<String>, - // #[arg(long)] - // /// Prefix the inferred id with something to avoid collisions - // ident_prefix: Option<String>, - // /// Copies media into the library - // #[arg(long)] - // copy: bool, - // /// Moves media into the library (potentially destructive operation) - // #[arg(long)] - // r#move: bool, - // /// Marks node as a video - // #[arg(long)] - // video: bool, - // /// Marks node as a series - // #[arg(short, long)] - // series: bool, - // /// Path to the media of the node, required for non-series - // #[arg(short, long)] - // input: Option<PathBuf>, - // /// Ignore attachments (dont use them as cover) - // #[arg(long)] - // ignore_attachments: bool, - // /// Ignore metadate (no title, description and tagline from input) - // #[arg(long)] - // ignore_metadata: bool, - // /// Skip any action that appears to be run already. - // #[arg(long)] - // skip_existing: bool, - // /// Sets the title - // #[arg(long)] - // title: Option<String>, - // }, Migrate { database: PathBuf, mode: MigrateMode, save_location: PathBuf, }, Reimport { - /// Path to global jellything config - config: PathBuf, /// Custom hostname, the config's is used by default #[arg(long)] hostname: Option<String>, @@ -106,6 +65,16 @@ fn main() -> anyhow::Result<()> { .init(); let args = Args::parse(); + let config = args + .config + .or(std::env::var_os("JELLYTHING_CONFIG").map(|p| PathBuf::from(p))) + .map(|path| { + Ok::<_, anyhow::Error>(serde_yaml::from_reader::<_, GlobalConfig>(File::open( + path, + )?)?) + }) + .transpose()?; + match args.action { Action::Init { base_path: path, @@ -163,19 +132,13 @@ fn main() -> anyhow::Result<()> { warn!("please change the admin password."); Ok(()) } - // a @ Action::New { .. } => import(a, args.dry), a @ Action::Migrate { .. } => migrate(a), - Action::Reimport { - config, - hostname, - no_tls, - } => tokio::runtime::Builder::new_multi_thread() + Action::Reimport { hostname, no_tls } => tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .unwrap() .block_on(async move { - let config = serde_yaml::from_reader::<_, GlobalConfig>(File::open(config)?)?; - + let config = config.ok_or(anyhow!("this action requires the config"))?; let inst = Instance::new(hostname.unwrap_or(config.hostname.clone()), !no_tls); info!("login"); let session = inst @@ -193,12 +156,12 @@ fn main() -> anyhow::Result<()> { } } -fn ok_or_warn<T, E: Debug>(r: Result<T, E>) -> Option<T> { - match r { - Ok(t) => Some(t), - Err(e) => { - warn!("{e:?}"); - None - } - } -} +// fn ok_or_warn<T, E: Debug>(r: Result<T, E>) -> Option<T> { +// match r { +// Ok(t) => Some(t), +// Err(e) => { +// warn!("{e:?}"); +// None +// } +// } +// } |