diff options
Diffstat (limited to 'tools/src/bin/import.rs')
-rw-r--r-- | tools/src/bin/import.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tools/src/bin/import.rs b/tools/src/bin/import.rs index 4af6ac7..d38925b 100644 --- a/tools/src/bin/import.rs +++ b/tools/src/bin/import.rs @@ -20,7 +20,7 @@ struct Args { dry: bool, #[clap(short = 'i', long)] - input: PathBuf, + input: Option<PathBuf>, } fn main() -> anyhow::Result<()> { @@ -37,20 +37,25 @@ fn main() -> anyhow::Result<()> { warn!("using the default instead"); ItemInfo { duration: 0.0, - path: args.input.clone(), - banner: args.banner, - title: args - .title - .unwrap_or(args.item.to_str().unwrap().to_string()), + banner: None, + title: args.item.to_str().unwrap().to_string(), tracks: Default::default(), } } }; - let input = File::open(args.input.clone()).unwrap(); - let mut input = EbmlReader::new(input); + if let Some(title) = args.title { + iteminfo.title = title; + } + if let Some(banner) = args.banner { + iteminfo.banner = Some(banner); + } - import_read(&mut input, &mut iteminfo)?; + if let Some(input_path) = args.input { + let input = File::open(input_path.clone()).unwrap(); + let mut input = EbmlReader::new(input); + import_read(&input_path, &mut input, &mut iteminfo)?; + } let k = serde_json::to_string_pretty(&iteminfo)?; if args.dry { @@ -59,6 +64,5 @@ fn main() -> anyhow::Result<()> { let mut f = File::create(args.item)?; f.write_all(k.as_bytes())?; } - Ok(()) } |