use ntex::web; use crate::util::requester::Requester; #[derive(Debug, Clone)] pub struct NoodlemagazineProxy { } impl NoodlemagazineProxy { pub fn new() -> Self { NoodlemagazineProxy { } } pub async fn get_video_url( &self, url: String, requester: web::types::State, ) -> String { let mut requester = requester.get_ref().clone(); let url = "https://noodlemagazine.com/".to_string() + &url; let text = requester.get(&url).await.unwrap_or("".to_string()); if text.is_empty() { return "".to_string(); } let json_str = text.split("window.playlist = ") .collect::>()[1] .split(";") .collect::>()[0]; let json: serde_json::Value = serde_json::from_str(json_str).unwrap(); let sources = json["sources"].as_array().unwrap(); let video_url = sources[0]["file"].as_str().unwrap().to_string(); return video_url; } }