From eb30d880cb91a5563e5dd4083c361078361984ce Mon Sep 17 00:00:00 2001 From: betta-cyber Date: Tue, 12 May 2020 11:00:51 +0800 Subject: [PATCH] [FIX] fix ncmt Read panicked at error thread task: reqwest::Error --- src/api.rs | 8 +++++++- src/player/fetch.rs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/api.rs b/src/api.rs index 8361946..466fde5 100644 --- a/src/api.rs +++ b/src/api.rs @@ -310,11 +310,16 @@ impl CloudMusic { "ids".to_owned(), serde_json::to_string(&vec![song_id]).unwrap_or("[]".to_owned()), ); - params.insert("br".to_owned(), 999000.to_string()); + // set br to 320000 + // if set br 990000 will get the flac music link + // but now I haven't finish the flac decode + params.insert("br".to_owned(), 320000.to_string()); // send request let result = self.post(&url, &mut params)?; let songs = self.convert_result::(&result); + + // debug!("songinfo {:#?}", songs); match songs { Ok(songs) => Ok(songs.data[0].clone()), Err(_) => Err(err_msg("get track url failed")), @@ -380,6 +385,7 @@ impl CloudMusic { } // other user playlist + #[allow(unused)] pub fn uid_playlists(&self, user_id: &str) -> Result, failure::Error> { let url = format!("/weapi/user/playlist"); let mut params = HashMap::new(); diff --git a/src/player/fetch.rs b/src/player/fetch.rs index 2191dd0..2f57f35 100644 --- a/src/player/fetch.rs +++ b/src/player/fetch.rs @@ -1,6 +1,6 @@ use std::io::prelude::*; use futures::channel::oneshot::Sender; -use reqwest::header::{CACHE_CONTROL, PRAGMA, HeaderMap, UPGRADE_INSECURE_REQUESTS, HOST, ACCEPT, ACCEPT_ENCODING, USER_AGENT}; +use reqwest::header::{CACHE_CONTROL, PRAGMA, HeaderMap, UPGRADE_INSECURE_REQUESTS, ACCEPT, ACCEPT_ENCODING, USER_AGENT}; use reqwest::Method; use tempfile::NamedTempFile; @@ -22,6 +22,7 @@ pub async fn fetch_data(url: &str, buffer: NamedTempFile, tx: Sender) -> "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0".parse().unwrap(), ); let client = reqwest::Client::builder() + // no need proxy but can add it in config // .proxy(reqwest::Proxy::all("socks5://127.0.0.1:3333").expect("proxy error")) .build().expect("builder error"); let builder = client.request(Method::GET, url).headers(headers);