diff options
Diffstat (limited to 'tools/src')
-rw-r--r-- | tools/src/bin/import.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tools/src/bin/import.rs b/tools/src/bin/import.rs index a27b247..471a669 100644 --- a/tools/src/bin/import.rs +++ b/tools/src/bin/import.rs @@ -10,7 +10,12 @@ use jellymatroska::read::EbmlReader; use jellyremuxer::import::import_read; use jellytools::tmdb::{tmdb_details, tmdb_image, tmdb_search}; use log::info; -use std::{fs::File, io::stdin, path::PathBuf, process::exit}; +use std::{ + fs::{remove_file, File}, + io::stdin, + path::PathBuf, + process::exit, +}; #[derive(Parser)] struct Args { @@ -27,6 +32,10 @@ enum Action { title: Option<String>, #[arg(short = 'T', long)] tmdb: Option<String>, + #[arg(long)] + copy: bool, + #[arg(long)] + r#move: bool, #[arg(short, long)] input: Option<PathBuf>, #[arg(short, long)] @@ -64,6 +73,8 @@ fn main() -> anyhow::Result<()> { tmdb: id, input, series, + copy, + r#move, } => { assert!(series || input.is_some(), "series or input required"); let kind = if series { "tv" } else { "movie" }; @@ -133,9 +144,16 @@ fn main() -> anyhow::Result<()> { if let Some(input) = input { let source_path = path.join(format!("source.mkv")); - // std::fs::rename(&input, &source_path)?; - // std::os::unix::fs::symlink(&input, &source_path)?; - std::fs::copy(&input, &source_path)?; + if r#move { + std::fs::rename(&input, &source_path)?; + } else if copy { + std::fs::copy(&input, &source_path)?; + } else { + if source_path.is_symlink() { + remove_file(&source_path)?; + } + std::os::unix::fs::symlink(&input, &source_path)?; + } let input = File::open(&source_path).unwrap(); let mut input = EbmlReader::new(input); let (tracks, local_tracks, seek_index, duration) = |