Skip to content

Commit

Permalink
[FIX] fix ncmt Read <unnamed> panicked at error thread task: reqwest:…
Browse files Browse the repository at this point in the history
…:Error
  • Loading branch information
betta-cyber committed May 12, 2020
1 parent 19e33bf commit eb30d88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Songs>(&result);

// debug!("songinfo {:#?}", songs);
match songs {
Ok(songs) => Ok(songs.data[0].clone()),
Err(_) => Err(err_msg("get track url failed")),
Expand Down Expand Up @@ -380,6 +385,7 @@ impl CloudMusic {
}

// other user playlist
#[allow(unused)]
pub fn uid_playlists(&self, user_id: &str) -> Result<Vec<Playlist>, failure::Error> {
let url = format!("/weapi/user/playlist");
let mut params = HashMap::new();
Expand Down
3 changes: 2 additions & 1 deletion src/player/fetch.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -22,6 +22,7 @@ pub async fn fetch_data(url: &str, buffer: NamedTempFile, tx: Sender<String>) ->
"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);
Expand Down

0 comments on commit eb30d88

Please sign in to comment.