xmpd/music_mgr/src/main.rs

42 lines
1.1 KiB
Rust
Raw Normal View History

2024-04-07 22:07:56 +00:00
use clap::Parser;
2024-04-08 00:03:35 +00:00
use crate::{cli::{CliArgs, CliCommand}, downloader::Downloader};
2024-04-07 22:07:56 +00:00
mod cli;
2024-04-08 00:03:35 +00:00
mod manifest;
mod logger;
mod downloader;
mod util;
2024-04-07 22:07:56 +00:00
2024-04-08 00:03:35 +00:00
#[tokio::main]
async fn main() {
2024-04-07 22:07:56 +00:00
let cli_args = CliArgs::parse();
2024-04-08 00:03:35 +00:00
logger::init_logger(cli_args.debug);
let manifest = match manifest::Manifest::from_path(&cli_args.manifest.as_std_path()) {
Ok(m) => m,
Err(e) => {
log::error!("Failed to parse manifest file {}: {e}", cli_args.manifest);
return;
}
};
let mut downloader = Downloader::new(util::get_ytdlp_path());
2024-04-07 22:07:56 +00:00
match cli_args.command {
2024-04-08 00:03:35 +00:00
None | Some(CliCommand::Download) => {
if let Ok(count) = downloader.download_all(manifest, &cli_args).await {
log::info!("Downloaded {count} songs");
} else {
log::error!("Failed to download songs");
return;
}
2024-04-07 22:07:56 +00:00
},
Some(c) => {
match c {
2024-04-08 00:03:35 +00:00
CliCommand::Download => unreachable!(),
CliCommand::Add { .. } => todo!(),
2024-04-07 22:07:56 +00:00
}
2024-04-08 00:03:35 +00:00
}
2024-04-07 22:07:56 +00:00
}
}