Spaces:
Paused
Paused
Upload 2 files
Browse filesFiles changed (2)
- src/api.rs+10-5
- src/main.rs+15-4
74 unmodified lines7576777879808182838419 unmodified lines1041051061071081091101111121131141151161174 unmodified lines12212312412512612712874 unmodified lineslet builder = Client::builder();let cookie = format!("arl={}; Domain=.deezer.com", arl);let url = "https://www.deezer.com".parse::<Url>().unwrap();let jar = Jar::default();jar.add_cookie_str(&cookie, &url);let builder = builder.cookie_provider(Arc::new(jar));Self {19 unmodified linescheck_form = &self.check_form;}let json: DeezerResponse = self.client.post("https://www.deezer.com/ajax/gw-light.php").query(&[("method", method),("input", "3"),("api_version", "1.0"),("api_token", check_form)]).header(ACCEPT, "*/*").header("Origin", "https://www.deezer.com")4 unmodified lines"User-Agent","Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",).json(params).send().await?.json()74 unmodified lines75767778798081828384858619 unmodified lines1061071081091101111121131141151161171181191201211221234 unmodified lines12812913013113213374 unmodified lineslet builder = Client::builder();let cookie = format!("arl={}; Domain=.deezer.com", arl);let comeback = "comeback=1; Domain=.deezer.com";let url = "https://www.deezer.com".parse::<Url>().unwrap();let jar = Jar::default();jar.add_cookie_str(&cookie, &url);jar.add_cookie_str(comeback, &url);let builder = builder.cookie_provider(Arc::new(jar));Self {19 unmodified linescheck_form = &self.check_form;}let url = "https://www.deezer.com/ajax/gw-light.php";let req = if method == "deezer.getUserData" {self.client.get(url)} else {self.client.post(url).json(params)};let json: DeezerResponse = req.query(&[("method", method),("input", "3"),("api_version", "1.0"),("api_token", check_form),]).header(ACCEPT, "*/*").header("Origin", "https://www.deezer.com")4 unmodified lines"User-Agent","Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",).send().await?.json()
381 unmodified lines3823833843853863873883899 unmodified lines39940040140240340440540640740840941013 unmodified lines424425426427428429381 unmodified linesapi_token: &str,params: serde_json::Value,) -> Result<serde_json::Value, String> {let r = client.post("https://www.deezer.com/ajax/gw-light.php").query(&[("method", method),("input", "3"),9 unmodified lines"User-Agent","Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",).json(¶ms).send().await.map_err(|_| "network".to_string())?;let json: GwResp = r.json().await.map_err(|_| "parse".to_string())?;if let Some(error) = json.error.as_object() {for (code, message) in error {13 unmodified linesreturn json_error(StatusCode::BAD_REQUEST, "Email and password_md5 required");}let jar = Jar::default();let client = reqwest::Client::builder().cookie_provider(Arc::new(jar)).timeout(std::time::Duration::from_secs(15))381 unmodified lines3823833843853863873883893903913923933949 unmodified lines40440540640740840941041141241341441541641741841913 unmodified lines433434435436437438439440381 unmodified linesapi_token: &str,params: serde_json::Value,) -> Result<serde_json::Value, String> {let url = "https://www.deezer.com/ajax/gw-light.php";let req = if method == "deezer.getUserData" {client.get(url)} else {client.post(url).json(¶ms)};let r = req.query(&[("method", method),("input", "3"),9 unmodified lines"User-Agent","Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",).send().await.map_err(|_| "network".to_string())?;let status = r.status();let text = r.text().await.map_err(|_| "read".to_string())?;let json: GwResp = serde_json::from_str(&text).map_err(|_| {let snip: String = text.chars().take(200).collect();format!("parse:{}:{}", status.as_u16(), snip)})?;if let Some(error) = json.error.as_object() {for (code, message) in error {13 unmodified linesreturn json_error(StatusCode::BAD_REQUEST, "Email and password_md5 required");}let jar = Jar::default();let url = "https://www.deezer.com".parse::<Url>().unwrap();jar.add_cookie_str("comeback=1; Domain=.deezer.com", &url);let client = reqwest::Client::builder().cookie_provider(Arc::new(jar)).timeout(std::time::Duration::from_secs(15))
src/api.rs+10-5
src/main.rs+15-4