diff --git a/src/args.rs b/src/args.rs index c9123cb..7349238 100644 --- a/src/args.rs +++ b/src/args.rs @@ -47,14 +47,6 @@ pub struct CLIArgs { )] pub conn_count: NonZeroU32, - #[clap( - short = 'z', - long = "zippy", - help = "The provided URLs are zippyshare URLs and need to be \ - resolved to direct download urls", - )] - pub zippy: bool, - #[clap( short = 'l', long = "listfile", diff --git a/src/main.rs b/src/main.rs index f0dfd50..cb668e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ use tokio::{ Mutex, }, }; +use zippy::is_zippyshare_url; use crate::{ args::CLIArgs, @@ -123,12 +124,12 @@ async fn download_job(urls: SyncQueue, reporter: UnboundedSender, cli_ let reporter = DlReporter::new(dlreq.id as u32, reporter.clone()); // Resolve the zippy url to the direct download url if necessary - let url = if cli_args.zippy { + let url = if is_zippyshare_url(&dlreq.url) { match zippy::resolve_link(&dlreq.url).await { Ok(url) => url, Err(_e) => { reporter.send(DlStatus::Message(format!( - "Zippyshare link could not be resolved: {}", + "Zippyshare link could not be resolved, skipping: {}", dlreq.url ))); continue; diff --git a/src/zippy.rs b/src/zippy.rs index 664fc4b..f0db94b 100644 --- a/src/zippy.rs +++ b/src/zippy.rs @@ -3,6 +3,12 @@ use std::io::{Error, ErrorKind}; use crate::errors::ResBE; +pub fn is_zippyshare_url(url: &str) -> bool { + Regex::new(r"^https?://(?:www\d*\.)?zippyshare\.com/v/[0-9a-zA-Z]+/file\.html$") + .unwrap() + .is_match(url) +} + /* Updated: 07.03.2022 Link generation code: