recycleactor commited on
Commit
e1c6aeb
·
verified ·
1 Parent(s): c091d8d

Upload 3 files

Browse files
Files changed (2) hide show
  1. Cargo.toml +1 -1
  2. src/main.rs +4 -5
Cargo.toml CHANGED
@@ -12,7 +12,7 @@ tower-http = { version = "0.5", features = ["cors", "trace", "compression-br", "
12
  tracing-subscriber = "0.3"
13
  tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
14
  serde = { version = "1.0", features = ["derive"] }
15
- reqwest = { version = "0.11", features = ["json", "rustls-tls", "cookies", "gzip"], default-features = false }
16
  serde_json = "1.0"
17
  thiserror = "1.0"
18
  bytes = "1"
 
12
  tracing-subscriber = "0.3"
13
  tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
14
  serde = { version = "1.0", features = ["derive"] }
15
+ reqwest = { version = "0.11", features = ["json", "rustls-tls", "cookies", "gzip", "stream"], default-features = false }
16
  serde_json = "1.0"
17
  thiserror = "1.0"
18
  bytes = "1"
src/main.rs CHANGED
@@ -18,6 +18,7 @@ use cipher::{KeyIvInit, BlockDecryptMut};
18
  use cipher::block_padding::NoPadding;
19
  use cbc::Decryptor;
20
  use reqwest::{cookie::Jar, Url};
 
21
 
22
  mod api;
23
  use api::{APIClient, APIError, Format};
@@ -146,7 +147,7 @@ fn blowfish_key(track_id: u32) -> [u8; 16] {
146
 
147
  fn decrypt_stripe(block: &mut [u8], key: &[u8; 16]) -> Result<(), ()> {
148
  let iv = [0u8, 1, 2, 3, 4, 5, 6, 7];
149
- let mut dec = Decryptor::<Blowfish>::new_from_slices(key, &iv).map_err(|_| ())?;
150
  dec.decrypt_padded_mut::<NoPadding>(block).map_err(|_| ())?;
151
  Ok(())
152
  }
@@ -225,7 +226,7 @@ async fn stream(State(state): State<Arc<RwLock<APIClient>>>, Query(q): Query<Str
225
  let mut carry: Vec<u8> = Vec::with_capacity(4096);
226
  let mut block_index: u64 = 0;
227
 
228
- let mut upstream = upstream.bytes_stream().map_err(|_| ());
229
 
230
  let out = async_stream::try_stream! {
231
  while let Some(chunk) = upstream.next().await {
@@ -337,7 +338,7 @@ async fn gw_light_call(
337
  ("api_version", "1.0"),
338
  ("api_token", api_token),
339
  ])
340
- .header(http::header::ACCEPT, "*/*")
341
  .json(&params)
342
  .send()
343
  .await
@@ -362,8 +363,6 @@ async fn login(Json(req): Json<LoginReq>) -> impl IntoResponse {
362
  if email.is_empty() || pass.is_empty() {
363
  return (StatusCode::BAD_REQUEST, "Email and password_md5 required".to_string()).into_response();
364
  }
365
-
366
- let url = "https://www.deezer.com".parse::<Url>().unwrap();
367
  let jar = Jar::default();
368
  let client = reqwest::Client::builder()
369
  .cookie_provider(Arc::new(jar))
 
18
  use cipher::block_padding::NoPadding;
19
  use cbc::Decryptor;
20
  use reqwest::{cookie::Jar, Url};
21
+ use reqwest::header::ACCEPT;
22
 
23
  mod api;
24
  use api::{APIClient, APIError, Format};
 
147
 
148
  fn decrypt_stripe(block: &mut [u8], key: &[u8; 16]) -> Result<(), ()> {
149
  let iv = [0u8, 1, 2, 3, 4, 5, 6, 7];
150
+ let dec = Decryptor::<Blowfish>::new_from_slices(key, &iv).map_err(|_| ())?;
151
  dec.decrypt_padded_mut::<NoPadding>(block).map_err(|_| ())?;
152
  Ok(())
153
  }
 
226
  let mut carry: Vec<u8> = Vec::with_capacity(4096);
227
  let mut block_index: u64 = 0;
228
 
229
+ let mut upstream = upstream.bytes_stream();
230
 
231
  let out = async_stream::try_stream! {
232
  while let Some(chunk) = upstream.next().await {
 
338
  ("api_version", "1.0"),
339
  ("api_token", api_token),
340
  ])
341
+ .header(ACCEPT, "*/*")
342
  .json(&params)
343
  .send()
344
  .await
 
363
  if email.is_empty() || pass.is_empty() {
364
  return (StatusCode::BAD_REQUEST, "Email and password_md5 required".to_string()).into_response();
365
  }
 
 
366
  let jar = Jar::default();
367
  let client = reqwest::Client::builder()
368
  .cookie_provider(Arc::new(jar))