Update zippyshare resolver 2022-07-24 + bump
- Bump version to 0.1.6
This commit is contained in:
parent
0f7e05a71d
commit
bc2d312ce9
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -183,7 +183,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ffdl"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ffdl"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
authors = ["daniel m <danielm@dnml.de>"]
|
||||
edition = "2021"
|
||||
description = "Download files fast"
|
||||
|
||||
@ -23,9 +23,13 @@ pub async fn resolve_link(url: &str) -> Result<String> {
|
||||
let body = reqwest::get(url).await?.text().await?;
|
||||
|
||||
// Try to extract the link using the latest extractor
|
||||
let link = extract_dl_link_2022_07_24(&host, &body).await;
|
||||
let link = extract_dl_link_2022_08_16(&host, &body).await;
|
||||
|
||||
// Try the previous extractors as fallback if it didn't work
|
||||
let link = match link {
|
||||
Err(_) => extract_dl_link_2022_07_24(&host, &body).await,
|
||||
ok => ok,
|
||||
};
|
||||
let link = match link {
|
||||
Err(_) => extract_dl_link_2022_07_17(&host, &body).await,
|
||||
ok => ok,
|
||||
@ -38,6 +42,73 @@ pub async fn resolve_link(url: &str) -> Result<String> {
|
||||
link
|
||||
}
|
||||
|
||||
/*
|
||||
Updated: 16.08.2022
|
||||
Link generation code:
|
||||
- `a` and `b` are random
|
||||
- `omg` is always `f`
|
||||
- the number used in the middle part `XXX%b` seems to be always the same as `a`
|
||||
|
||||
```
|
||||
var a = 634851;
|
||||
var b = 958673;
|
||||
document.getElementById('dlbutton').omg = "f";
|
||||
if (document.getElementById('dlbutton').omg != 'f') {
|
||||
a = Math.ceil(a/3);
|
||||
} else {
|
||||
a = Math.floor(a/3);
|
||||
}
|
||||
document.getElementById('dlbutton').href = "/d/gue47sk7/"+(a + 634851%b)+"/some-file-name.part1.rar";
|
||||
```
|
||||
*/
|
||||
pub async fn extract_dl_link_2022_08_16(host: &str, body: &str) -> Result<String> {
|
||||
let re_a = Regex::new(r#"var a = (\d+);"#)?;
|
||||
let re_b = Regex::new(r#"var b = (\d+);"#)?;
|
||||
|
||||
let re_link = Regex::new(
|
||||
r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)"\+\(a \+ (\d+)%b\)\+"(.+)";"#,
|
||||
)?;
|
||||
|
||||
if !body.contains(
|
||||
r#"document.getElementById('dlbutton').omg = "f";
|
||||
if (document.getElementById('dlbutton').omg != 'f') {
|
||||
a = Math.ceil(a/3);
|
||||
} else {
|
||||
a = Math.floor(a/3);
|
||||
}"#,
|
||||
) {
|
||||
return Err(Error::new(ErrorKind::Other, "omg part of the link-gen not found").into());
|
||||
}
|
||||
|
||||
let cap_a = match re_a.captures(body) {
|
||||
Some(cap) => cap,
|
||||
None => return Err(Error::new(ErrorKind::Other, "Link not found").into()),
|
||||
};
|
||||
|
||||
let cap_b = match re_b.captures(body) {
|
||||
Some(cap) => cap,
|
||||
None => return Err(Error::new(ErrorKind::Other, "Link not found").into()),
|
||||
};
|
||||
|
||||
let cap_link = match re_link.captures(body) {
|
||||
Some(cap) => cap,
|
||||
None => return Err(Error::new(ErrorKind::Other, "Link not found").into()),
|
||||
};
|
||||
|
||||
let a: i64 = cap_a[1].parse()?;
|
||||
let b: i64 = cap_b[1].parse()?;
|
||||
|
||||
let url_start = &cap_link[1];
|
||||
let n1: i64 = cap_link[2].parse()?;
|
||||
let url_end = &cap_link[3];
|
||||
|
||||
let middle = (a / 3) + n1 % b;
|
||||
|
||||
let dl_url = format!("{}{}{}{}", &host, url_start, middle, url_end);
|
||||
|
||||
Ok(dl_url)
|
||||
}
|
||||
|
||||
/*
|
||||
Updated: 24.07.2022
|
||||
Link generation code:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user