diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-03 19:14:26 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-03 19:14:26 +0200 |
commit | c71a10717392cc321b97e3f2173645e78c263488 (patch) | |
tree | d55187e9417bc186735c3615f5e3d0f07dfb6ffb /tools/src | |
parent | df768b33d0098a479b21abe30853537b4be3a813 (diff) | |
download | jellything-c71a10717392cc321b97e3f2173645e78c263488.tar jellything-c71a10717392cc321b97e3f2173645e78c263488.tar.bz2 jellything-c71a10717392cc321b97e3f2173645e78c263488.tar.zst |
symlink sources
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) = |