diff options
author | metamuffin <metamuffin@disroot.org> | 2023-12-17 14:49:19 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-12-17 14:49:19 +0100 |
commit | 2e6f2a2d21a0ba9a5c8f13bf27e64615144cf222 (patch) | |
tree | e48550f7c9a4d7235df9df62d993ec2213b09fd7 /tool/src | |
parent | 908f05cb992238b93466b382edcaac1aea83de9a (diff) | |
download | jellything-2e6f2a2d21a0ba9a5c8f13bf27e64615144cf222.tar jellything-2e6f2a2d21a0ba9a5c8f13bf27e64615144cf222.tar.bz2 jellything-2e6f2a2d21a0ba9a5c8f13bf27e64615144cf222.tar.zst |
tool: skip existing option
Diffstat (limited to 'tool/src')
-rw-r--r-- | tool/src/import/mod.rs | 15 | ||||
-rw-r--r-- | tool/src/main.rs | 9 |
2 files changed, 20 insertions, 4 deletions
diff --git a/tool/src/import/mod.rs b/tool/src/import/mod.rs index fb42c4d..b4e03d6 100644 --- a/tool/src/import/mod.rs +++ b/tool/src/import/mod.rs @@ -15,7 +15,7 @@ use jellycommon::{ }; use jellymatroska::read::EbmlReader; use jellyremuxer::import::import_metadata; -use log::{info, warn}; +use log::{debug, info, warn}; use std::{ collections::BTreeMap, fs::{remove_file, File}, @@ -37,11 +37,24 @@ pub(crate) fn import(action: Action, dry: bool) -> anyhow::Result<()> { video, ignore_metadata, r#move, + skip_existing, } => { if std::env::current_dir().unwrap().file_name().unwrap() != "library" { warn!("new command can only be used in the library directory; what you are doing right now probably wont work.") } + if skip_existing { + if let Some(input) = &input { + let guessed_path = path.join(input.file_stem().unwrap_or(input.as_os_str())); + if guessed_path.exists() { + info!("guessed output ({guessed_path:?}) exists, skipping import"); + return Ok(()); + } else { + debug!("guessed output ({guessed_path:?}) missing"); + } + } + } + let tmdb_kind = if series { "tv" } else { "movie" }; let tmdb_id = if let Some(id) = tmdb_id { Some(id.parse().unwrap()) diff --git a/tool/src/main.rs b/tool/src/main.rs index 47c9a53..3744560 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -59,18 +59,21 @@ enum Action { /// Marks node as a video #[arg(long)] video: bool, - /// Path to the media of the node, required for non-series - #[arg(short, long)] - input: Option<PathBuf>, /// 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, }, Migrate { database: PathBuf, |