From cadb3057d06a38abfac9067cbdc59ce3d926a658 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 19 Jan 2023 09:02:16 +0100 Subject: item page styled --- tools/src/bin/import.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'tools/src/bin/import.rs') diff --git a/tools/src/bin/import.rs b/tools/src/bin/import.rs index 98f5fb7..4af6ac7 100644 --- a/tools/src/bin/import.rs +++ b/tools/src/bin/import.rs @@ -2,26 +2,51 @@ use clap::Parser; use jellycommon::ItemInfo; use jellymatroska::read::EbmlReader; use jellyremuxer::import::import_read; +use log::warn; use std::{fs::File, io::Write, path::PathBuf}; #[derive(Parser)] struct Args { #[clap(short = 'I', long)] item: PathBuf, + + #[clap(short, long)] + banner: Option, + + #[clap(short, long)] + title: Option, + #[clap(short = 'd', long)] dry: bool, + #[clap(short = 'i', long)] input: PathBuf, } fn main() -> anyhow::Result<()> { - env_logger::init_from_env("LOG"); + env_logger::builder() + .filter_level(log::LevelFilter::Info) + .parse_env("LOG") + .init(); let args = Args::parse(); - let mut iteminfo: ItemInfo = serde_json::from_reader(File::open(&args.item)?)?; - // let iteminfo_orig = iteminfo.clone(); + let mut iteminfo: ItemInfo = match File::open(&args.item) { + Ok(f) => serde_json::from_reader(f)?, + Err(e) => { + warn!("could not load item info: {e}"); + 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()), + tracks: Default::default(), + } + } + }; - iteminfo.path = args.input.to_str().unwrap().to_string(); let input = File::open(args.input.clone()).unwrap(); let mut input = EbmlReader::new(input); -- cgit v1.2.3-70-g09d2