Autodetect zippyshare links

- Removed `-z` zippyshare resolver
- Automatically detect zippyshare urls and resolve them
This commit is contained in:
Daniel M 2022-03-31 16:53:49 +02:00
parent 59de02d34d
commit 2cf9594fa9
3 changed files with 9 additions and 10 deletions

View File

@ -47,14 +47,6 @@ pub struct CLIArgs {
)] )]
pub conn_count: NonZeroU32, 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( #[clap(
short = 'l', short = 'l',
long = "listfile", long = "listfile",

View File

@ -16,6 +16,7 @@ use tokio::{
Mutex, Mutex,
}, },
}; };
use zippy::is_zippyshare_url;
use crate::{ use crate::{
args::CLIArgs, args::CLIArgs,
@ -123,12 +124,12 @@ async fn download_job(urls: SyncQueue, reporter: UnboundedSender<DlReport>, cli_
let reporter = DlReporter::new(dlreq.id as u32, reporter.clone()); let reporter = DlReporter::new(dlreq.id as u32, reporter.clone());
// Resolve the zippy url to the direct download url if necessary // 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 { match zippy::resolve_link(&dlreq.url).await {
Ok(url) => url, Ok(url) => url,
Err(_e) => { Err(_e) => {
reporter.send(DlStatus::Message(format!( reporter.send(DlStatus::Message(format!(
"Zippyshare link could not be resolved: {}", "Zippyshare link could not be resolved, skipping: {}",
dlreq.url dlreq.url
))); )));
continue; continue;

View File

@ -3,6 +3,12 @@ use std::io::{Error, ErrorKind};
use crate::errors::ResBE; 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 Updated: 07.03.2022
Link generation code: Link generation code: