Autodetect zippyshare links
- Removed `-z` zippyshare resolver - Automatically detect zippyshare urls and resolve them
This commit is contained in:
parent
59de02d34d
commit
2cf9594fa9
@ -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",
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -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:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user