some scraper stuff

This commit is contained in:
Zastian Pretorius
2023-02-01 20:18:36 +00:00
parent edbebf4b4e
commit 6fadcadba1
2 changed files with 12 additions and 11 deletions

View File

@@ -82,7 +82,7 @@ pub fn get_episode_link(ep_id: &str, provider: &str) -> (String, String) {
.unwrap();
let json = req.send().unwrap().text().unwrap();
let json: serde_json::Value = serde_json::from_str(&json).unwrap();
let url = "";
let mut url = String::new();
std::fs::write("test.json", json.to_string()).unwrap();
let mut subtitle = String::new();
let _error_vec = Vec::new();
@@ -98,16 +98,17 @@ pub fn get_episode_link(ep_id: &str, provider: &str) -> (String, String) {
subtitle = subtitle.replace(":", "\\:");
}
}
let mut highest_quality = 0;
for i in 0..json["sources"].as_array().unwrap().len() {
if json["sources"][i]["quality"]
let quality = json["sources"][i]["quality"]
.as_str()
.unwrap()
.contains("1080")
{
return (
json["sources"][i]["url"].as_str().unwrap().to_string(),
subtitle,
);
.replace("p", "")
.parse::<i32>()
.unwrap_or(0);
if quality > highest_quality {
highest_quality = quality;
url = json["sources"][i]["url"].as_str().unwrap().to_string();
}
}
(url.to_string(), subtitle)

View File

@@ -17,7 +17,7 @@ fn main() {
let mut chapter: u32 = 0;
//let search = option string
let mut count = 0;
let mut provider: String = "gogo".to_string();
let mut provider: String = "zoro".to_string();
let mut cast = (false, "0".to_string());
for arg in std::env::args() {
if arg == "--help" || arg == "-h" {
@@ -36,10 +36,10 @@ fn main() {
provider = "gogoanime".to_string();
count += 1;
} else {
provider = "zoro".to_string();
provider = "gogo".to_string();
}
} else {
provider = "zoro".to_string();
provider = "gogo".to_string();
}
}
if arg == "--cast" || arg == "-C" {