Update zippyshare resolver
This commit is contained in:
parent
33f559ad4f
commit
105a70447a
39
src/zippy.rs
39
src/zippy.rs
@ -3,6 +3,22 @@ use std::io::{ Error, ErrorKind };
|
||||
|
||||
use crate::errors::ResBE;
|
||||
|
||||
/*
|
||||
Updated: 08.01.2022
|
||||
Link generation code:
|
||||
- `n`, `b` and `z` are dynamic (random) on each reload
|
||||
- `%2` and `%3` for n and b don't change
|
||||
- The main number for `n` and `b` is always equal
|
||||
- `z` is always the `n`/`b` main number + 3
|
||||
- Link middle part calculation stays the same
|
||||
|
||||
```
|
||||
var n = 794218%2;
|
||||
var b = 794218%3;
|
||||
var z = 794221;
|
||||
document.getElementById('dlbutton').href = "/d/0Ky7p1C6/"+(n + b + z - 3)+"/some-file-name.part1.rar";
|
||||
```
|
||||
*/
|
||||
pub async fn resolve_link(url: &str) -> ResBE<String> {
|
||||
|
||||
// Regex to check if the provided url is a zippyshare download url
|
||||
@ -19,21 +35,28 @@ pub async fn resolve_link(url: &str) -> ResBE<String> {
|
||||
.text().await?;
|
||||
|
||||
// Regex to match the javascript part of the html that generates the real download link
|
||||
let re_all = Regex::new(r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)" \+ \((\d+) % (\d+) \+ (\d+) % (\d+)\) \+ "(.+)";"#)?;
|
||||
let re_link = Regex::new(r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)"\+\(.+\)\+"(.+)";"#)?;
|
||||
let re_z = Regex::new(r#"var z = (\d+);"#)?;
|
||||
|
||||
let cap_all = match re_all.captures(&body) {
|
||||
let cap_link = match re_link.captures(&body) {
|
||||
Some(cap) => cap,
|
||||
None => return Err(Error::new(ErrorKind::Other, "Link not found").into())
|
||||
};
|
||||
|
||||
let a: i32 = i32::from_str_radix(&cap_all[2], 10)?;
|
||||
let b: i32 = i32::from_str_radix(&cap_all[3], 10)?;
|
||||
let c: i32 = i32::from_str_radix(&cap_all[4], 10)?;
|
||||
let d: i32 = i32::from_str_radix(&cap_all[5], 10)?;
|
||||
let cap_z = match re_z.captures(&body) {
|
||||
Some(cap) => cap,
|
||||
None => return Err(Error::new(ErrorKind::Other, "Link not found").into())
|
||||
};
|
||||
|
||||
let mixed = a % b + c % d;
|
||||
let url_start = &cap_link[1];
|
||||
let url_end = &cap_link[2];
|
||||
let z: i32 = i32::from_str_radix(&cap_z[1], 10)?;
|
||||
let n = (z - 3) % 2;
|
||||
let b = (z - 3) % 3;
|
||||
|
||||
let dl_url = format!("{}{}{}{}", &base_host, &cap_all[1], mixed, &cap_all[6]);
|
||||
let mixed = n + b + z - 3;
|
||||
|
||||
let dl_url = format!("{}{}{}{}", &base_host, url_start, mixed, url_end);
|
||||
|
||||
Ok(dl_url)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user