Update zippy share resolver 2022-03-07

This commit is contained in:
Daniel M 2022-03-07 14:28:06 +01:00
parent 105a70447a
commit 29475dd3bd

View File

@ -4,19 +4,17 @@ use std::io::{ Error, ErrorKind };
use crate::errors::ResBE;
/*
Updated: 08.01.2022
Updated: 07.03.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
- `href = $1 + ($2 % $3 + $4 % $5) + $6`
- `$1` is always `/d/XXX` where XXX is dependent on the file
- `$2`, `$3`, `$4` and `$5` are dynamic and randomly generated on each reload
- `$2` is always the same as `$4`
- `$6` is dependent on the file
- The numbers in the calculation part ($2`, `$3`, `$4` and `$5`) are hard coded
```
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";
document.getElementById('dlbutton').href = "/d/0Ky7p1C6/" + (186549 % 51245 + 186549 % 913) + "/some-file-name.part1.rar";
```
*/
pub async fn resolve_link(url: &str) -> ResBE<String> {
@ -35,26 +33,21 @@ 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_link = Regex::new(r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)"\+\(.+\)\+"(.+)";"#)?;
let re_z = Regex::new(r#"var z = (\d+);"#)?;
let re_link = Regex::new(r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)" \+ \((\d+) % (\d+) \+ \d+ % (\d+)\) \+ "(.+)";"#)?;
let cap_link = match re_link.captures(&body) {
Some(cap) => cap,
None => return Err(Error::new(ErrorKind::Other, "Link not found").into())
};
let cap_z = match re_z.captures(&body) {
Some(cap) => cap,
None => return Err(Error::new(ErrorKind::Other, "Link not found").into())
};
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 url_end = &cap_link[5];
let n2: i32 = i32::from_str_radix(&cap_link[2], 10)?;
let n3: i32 = i32::from_str_radix(&cap_link[3], 10)?;
let n4 = n2;
let n5: i32 = i32::from_str_radix(&cap_link[4], 10)?;
let mixed = n + b + z - 3;
let mixed = n2 % n3 + n4 % n5;
let dl_url = format!("{}{}{}{}", &base_host, url_start, mixed, url_end);