Update zippyshare resolver 2022-07-24 + bump

- Bump version to 0.1.5
This commit is contained in:
Daniel M 2022-07-24 15:39:00 +02:00
parent 2e0c12ee56
commit 0f7e05a71d
3 changed files with 61 additions and 8 deletions

2
Cargo.lock generated
View File

@ -183,7 +183,7 @@ dependencies = [
[[package]] [[package]]
name = "ffdl" name = "ffdl"
version = "0.1.4" version = "0.1.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ffdl" name = "ffdl"
version = "0.1.4" version = "0.1.5"
authors = ["daniel m <danielm@dnml.de>"] authors = ["daniel m <danielm@dnml.de>"]
edition = "2021" edition = "2021"
description = "Download files fast" description = "Download files fast"

View File

@ -23,8 +23,13 @@ pub async fn resolve_link(url: &str) -> Result<String> {
let body = reqwest::get(url).await?.text().await?; let body = reqwest::get(url).await?.text().await?;
// Try to extract the link using the latest extractor // Try to extract the link using the latest extractor
let link = extract_dl_link_2022_07_17(&host, &body).await; let link = extract_dl_link_2022_07_24(&host, &body).await;
// Try the previous extractor as fallback if it didn't work
// Try the previous extractors as fallback if it didn't work
let link = match link {
Err(_) => extract_dl_link_2022_07_17(&host, &body).await,
ok => ok,
};
let link = match link { let link = match link {
Err(_) => extract_dl_link_2022_03_07(&host, &body).await, Err(_) => extract_dl_link_2022_03_07(&host, &body).await,
ok => ok, ok => ok,
@ -33,6 +38,56 @@ pub async fn resolve_link(url: &str) -> Result<String> {
link link
} }
/*
Updated: 24.07.2022
Link generation code:
```
<span id="omg" class="2" style="display:none;"></span>
<script type="text/javascript">
var a = function() {return 1};
var b = function() {return a() + 1};
var c = function() {return b() + 1};
var d = document.getElementById('omg').getAttribute('class');
if (true) { d = d*2;}
document.getElementById('dlbutton').href = "/d/gue47sk7/"+(34556%1000 + a() + b() + c() + d + 5/5)+"/some-file-name.part1.rar";
```
*/
pub async fn extract_dl_link_2022_07_24(host: &str, body: &str) -> Result<String> {
let re_link = Regex::new(
r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)"\+\((\d+)%1000 \+ a\(\) \+ b\(\) \+ c\(\) \+ d \+ 5/5\)\+"(.+)";"#,
)?;
if !body.contains(r#"<span id="omg" class="2" style="display:none;"></span>"#) {
return Err(Error::new(ErrorKind::Other, "span part of the link-gen not found").into());
}
if !body.contains(
r#"var a = function() {return 1};
var b = function() {return a() + 1};
var c = function() {return b() + 1};
var d = document.getElementById('omg').getAttribute('class');
if (true) { d = d*2;}"#,
) {
return Err(Error::new(ErrorKind::Other, "script part of the link-gen 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 url_start = &cap_link[1];
let n1: u64 = cap_link[2].parse()?;
let url_end = &cap_link[3];
let middle = n1 % 1000 + 11;
let dl_url = format!("{}{}{}{}", &host, url_start, middle, url_end);
Ok(dl_url)
}
/* /*
Updated: 17.07.2022 Updated: 17.07.2022
Link generation code: Link generation code:
@ -51,15 +106,13 @@ document.getElementById('dlbutton').href = "/d/0Ky7p1C6/"+(Math.pow(a, 3)+b)+"/s
``` ```
*/ */
pub async fn extract_dl_link_2022_07_17(host: &str, body: &str) -> Result<String> { pub async fn extract_dl_link_2022_07_17(host: &str, body: &str) -> Result<String> {
let re_var_a = Regex::new( let re_var_a = Regex::new(r#"var a = (\d+);"#)?;
r#"var a = (\d+);"#
)?;
// Regex to match the javascript part of the html that generates the real download link // Regex to match the javascript part of the html that generates the real download link
let re_link = Regex::new( let re_link = Regex::new(
r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)"\+\(Math\.pow\(a, 3\)\+b\)\+"(.+)";"#, r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)"\+\(Math\.pow\(a, 3\)\+b\)\+"(.+)";"#,
)?; )?;
let cap_var_a = match re_var_a.captures(&body) { let cap_var_a = match re_var_a.captures(&body) {
Some(cap) => cap, Some(cap) => cap,
None => return Err(Error::new(ErrorKind::Other, "Var a not found").into()), None => return Err(Error::new(ErrorKind::Other, "Var a not found").into()),