added new providers

This commit is contained in:
Zastian Pretorius
2022-11-04 14:37:07 +00:00
parent 1fc1b7e867
commit 3abedb7360
3 changed files with 76 additions and 25 deletions

View File

@@ -77,7 +77,7 @@ pub fn get_anime_info(title: &str) -> (i32, u16) {
)
}
pub fn anime_link(title: &str, ep: u64) -> (String, String) {
pub fn anime_link(title: &str, ep: u64, provider: &str) -> (String, String) {
let url = format!("https://animixplay.to/v1/{}", title);
let html = get_anime_html(&url);
let re = Regex::new(r#"(?m)\?id=([^&]+)"#).unwrap();
@@ -86,27 +86,42 @@ pub fn anime_link(title: &str, ep: u64) -> (String, String) {
None => "".to_string(),
};
if id1 != "" {
let title = format!("{} Episode {}", title.replace('-', " "), ep);
let encoded_id1 = encode(&id1);
let encoded_id2 = encode(&encoded_id1);
let mut last_byte = encoded_id1.as_bytes()[encoded_id1.len() - 2];
last_byte += 1;
let mut new_encoded_id1 = encoded_id1.as_bytes().to_vec();
new_encoded_id1.pop();
new_encoded_id1.pop();
new_encoded_id1.push(last_byte);
let new_encoded_id1 = String::from_utf8(new_encoded_id1).unwrap();
let ani_id = format!("cW9{}MVFhzM0dyVTh3ZTlP{}", new_encoded_id1, encoded_id2);
let result = get_ep_location(format!("https://animixplay.to/api/{}", ani_id).as_str());
//split the result into at # and return the second part
let result: String = std::str::from_utf8(
decode(result.split('#').nth(1).unwrap())
if provider == "vrv" {
let title = format!("{} Episode {}", title.replace('-', " "), ep);
let encoded_id1 = encode(&id1);
let encoded_id2 = encode(&encoded_id1);
let mut last_byte = encoded_id1.as_bytes()[encoded_id1.len() - 2];
last_byte += 1;
let mut new_encoded_id1 = encoded_id1.as_bytes().to_vec();
new_encoded_id1.pop();
new_encoded_id1.pop();
new_encoded_id1.push(last_byte);
let new_encoded_id1 = String::from_utf8(new_encoded_id1).unwrap();
let ani_id = format!("cW9{}MVFhzM0dyVTh3ZTlP{}", new_encoded_id1, encoded_id2);
let result = get_ep_location(format!("https://animixplay.to/api/{}", ani_id).as_str());
//split the result into at # and return the second part
let result: String = std::str::from_utf8(
decode(result.split('#').nth(1).unwrap())
.unwrap()
.as_slice(),
)
.unwrap()
.to_string();
return (result, title);
} else if provider == "gogo" {
let title = format!("{} Episode {}", title.replace('-', " "), ep);
let encoded_id1 = encode(&id1);
let anime_id = encode(format!("{}LTXs3GrU8we9O{}", id1, encoded_id1));
let html = format!("https://animixplay.to/api/live{}", anime_id);
let url = get_ep_location(&html);
let url = url.split('#').nth(1).unwrap();
let url = std::str::from_utf8(&decode(url).unwrap())
.unwrap()
.as_slice(),
)
.unwrap()
.to_string();
return (result, title);
.to_string();
return (url, title);
} else {
panic!("Invalid provider");
}
} else {
let re = Regex::new(r#"(?m)r\.html#(.*)""#).unwrap();
let id2 = re