Skip to content

Commit

Permalink
Fix some stuff that was broken due to weirdness of tori
Browse files Browse the repository at this point in the history
  • Loading branch information
lajp committed Nov 16, 2021
1 parent 38d694a commit 30f8bbf
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/vahti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,27 @@ fn vahti_to_api(vahti: &str) -> String {
// because in the API category=0 yealds no results and in the search it just means
// no category was specified
url = url.replace("&category=0", "");
if url.contains("w=") {
let region;
let index = url.find("w=").unwrap();
let endindex = url[index..].find('&').unwrap_or(url.len()-index);
let num = url[index+2..endindex+index].parse::<i32>().unwrap();
if num >= 100 {
region = num-100;
} else if url.contains("ca=") {
let nindex = url.find("ca=").unwrap();
let nendindex = url[nindex..].find('&').unwrap_or(url.len()-nindex);
let num = url[nindex+3..nendindex+nindex].parse::<i32>().unwrap();
region = num;
} else {
region = num;
}
url = url.replace(&url[index..endindex+index], &format!("region={}", region));
} else {
url = url.replace("ca=", "region=");
}
url = url.replace("st=", "ad_type=");
url = url.replace("m=", "area=");
url = url.replace("ca=", "region=");
url = url.replace("_s", ""); // FIXME: not a good solution
if price_set {
url = url + &format!("&suborder={}-{}", &startprice, &endprice);
Expand Down

0 comments on commit 30f8bbf

Please sign in to comment.