recycleactor commited on
Commit
5c3e5a4
·
verified ·
1 Parent(s): e4cd48a

Upload 2 files

Browse files
Files changed (2) hide show
  1. src/api.rs +2 -2
  2. src/main.rs +19 -0
src/api.rs CHANGED
@@ -64,7 +64,7 @@ impl APIClient {
64
  match env::var("ARL") {
65
  Ok(arl) if !arl.trim().is_empty() => Self::new_with_arl(arl),
66
  _ => Self {
67
- client: Client::builder().build().unwrap(),
68
  license_token: String::new(),
69
  check_form: String::new(),
70
  renew_instant: None,
@@ -73,7 +73,7 @@ impl APIClient {
73
  }
74
 
75
  pub fn new_with_arl(arl: String) -> Self {
76
- let builder = Client::builder();
77
 
78
  let cookie = format!("arl={}; Domain=.deezer.com", arl);
79
  let comeback = "comeback=1; Domain=.deezer.com";
 
64
  match env::var("ARL") {
65
  Ok(arl) if !arl.trim().is_empty() => Self::new_with_arl(arl),
66
  _ => Self {
67
+ client: Client::builder().no_proxy().build().unwrap(),
68
  license_token: String::new(),
69
  check_form: String::new(),
70
  renew_instant: None,
 
73
  }
74
 
75
  pub fn new_with_arl(arl: String) -> Self {
76
+ let builder = Client::builder().no_proxy();
77
 
78
  let cookie = format!("arl={}; Domain=.deezer.com", arl);
79
  let comeback = "comeback=1; Domain=.deezer.com";
src/main.rs CHANGED
@@ -192,6 +192,7 @@ async fn upstream_get_url_text(formats: &Vec<Format>, ids: &Vec<u32>) -> Result<
192
  let url = format!("{base}/get_url");
193
 
194
  let client = reqwest::Client::builder()
 
195
  .timeout(std::time::Duration::from_secs(20))
196
  .build()
197
  .map_err(|_| "upstream:client".to_string())?;
@@ -224,6 +225,7 @@ async fn upstream_media_url(id: u32, formats: &Vec<Format>) -> Result<String, St
224
 
225
  async fn public_track_duration(id: u32) -> Option<u32> {
226
  let client = reqwest::Client::builder()
 
227
  .timeout(std::time::Duration::from_secs(10))
228
  .build()
229
  .ok()?;
@@ -330,6 +332,7 @@ async fn fetch(Query(q): Query<FetchParams>) -> impl IntoResponse {
330
  }
331
 
332
  let client = reqwest::Client::builder()
 
333
  .timeout(std::time::Duration::from_secs(60))
334
  .build()
335
  .unwrap();
@@ -456,6 +459,7 @@ async fn stream_info(State(state): State<AppState>, Query(q): Query<StreamParams
456
 
457
  let duration = public_track_duration(q.id).await.unwrap_or(0);
458
  let http = reqwest::Client::builder()
 
459
  .timeout(std::time::Duration::from_secs(15))
460
  .build()
461
  .unwrap();
@@ -620,6 +624,7 @@ async fn stream(
620
  .and_then(parse_range_header);
621
 
622
  let http = reqwest::Client::builder()
 
623
  .timeout(std::time::Duration::from_secs(60))
624
  .build()
625
  .unwrap();
@@ -1162,6 +1167,7 @@ async fn login(Json(req): Json<LoginReq>) -> impl IntoResponse {
1162
  let url_deezer = "https://www.deezer.com".parse::<Url>().unwrap();
1163
  jar.add_cookie_str("comeback=1; Domain=.deezer.com", &url_deezer);
1164
  let client = reqwest::Client::builder()
 
1165
  .cookie_provider(jar.clone())
1166
  .timeout(std::time::Duration::from_secs(15))
1167
  .build()
@@ -1587,6 +1593,7 @@ async fn pair_complete(State(state): State<AppState>, Form(f): Form<PairComplete
1587
  let url_deezer = "https://www.deezer.com".parse::<Url>().unwrap();
1588
  jar.add_cookie_str("comeback=1; Domain=.deezer.com", &url_deezer);
1589
  let client = reqwest::Client::builder()
 
1590
  .cookie_provider(jar.clone())
1591
  .timeout(std::time::Duration::from_secs(20))
1592
  .build()
@@ -1737,9 +1744,11 @@ async fn oauth_me(Json(req): Json<OauthMeReq>) -> impl IntoResponse {
1737
  return json_error(StatusCode::BAD_REQUEST, "access_token required");
1738
  }
1739
  let client = reqwest::Client::builder()
 
1740
  .timeout(std::time::Duration::from_secs(15))
1741
  .build()
1742
  .unwrap();
 
1743
  match api_deezer_get(&client, "/user/me", &token, &[]).await {
1744
  Ok(v) => (StatusCode::OK, Json(v)).into_response(),
1745
  Err(e) => json_error(StatusCode::SERVICE_UNAVAILABLE, e),
@@ -1761,9 +1770,11 @@ async fn oauth_playlists(Json(req): Json<OauthPlaylistsReq>) -> impl IntoRespons
1761
  let index = req.index.unwrap_or(0).to_string();
1762
  let limit = req.limit.unwrap_or(50).to_string();
1763
  let client = reqwest::Client::builder()
 
1764
  .timeout(std::time::Duration::from_secs(15))
1765
  .build()
1766
  .unwrap();
 
1767
  let me = match api_deezer_get(&client, "/user/me", &token, &[]).await {
1768
  Ok(v) => v,
1769
  Err(e) => return json_error(StatusCode::SERVICE_UNAVAILABLE, e),
@@ -1799,9 +1810,11 @@ async fn oauth_playlist_tracks(Json(req): Json<OauthPlaylistTracksReq>) -> impl
1799
  let index = req.index.unwrap_or(0).to_string();
1800
  let limit = req.limit.unwrap_or(100).to_string();
1801
  let client = reqwest::Client::builder()
 
1802
  .timeout(std::time::Duration::from_secs(15))
1803
  .build()
1804
  .unwrap();
 
1805
  let path = format!("/playlist/{}/tracks", req.playlist_id);
1806
  let extra = [("index", index), ("limit", limit)];
1807
  match api_deezer_get(&client, &path, &token, &extra).await {
@@ -2151,6 +2164,7 @@ async fn oauth_flow(Json(req): Json<OauthFlowReq>) -> impl IntoResponse {
2151
  }
2152
  let limit = req.limit.unwrap_or(40).clamp(1, 100).to_string();
2153
  let client = reqwest::Client::builder()
 
2154
  .timeout(std::time::Duration::from_secs(15))
2155
  .build()
2156
  .unwrap();
@@ -2187,6 +2201,7 @@ async fn oauth_reco_playlists(Json(req): Json<OauthRecoReq>) -> impl IntoRespons
2187
  let index = req.index.unwrap_or(0).to_string();
2188
  let limit = req.limit.unwrap_or(20).clamp(1, 50).to_string();
2189
  let client = reqwest::Client::builder()
 
2190
  .timeout(std::time::Duration::from_secs(15))
2191
  .build()
2192
  .unwrap();
@@ -2215,6 +2230,7 @@ async fn oauth_reco_albums(Json(req): Json<OauthRecoReq>) -> impl IntoResponse {
2215
  let index = req.index.unwrap_or(0).to_string();
2216
  let limit = req.limit.unwrap_or(20).clamp(1, 50).to_string();
2217
  let client = reqwest::Client::builder()
 
2218
  .timeout(std::time::Duration::from_secs(15))
2219
  .build()
2220
  .unwrap();
@@ -2243,6 +2259,7 @@ async fn oauth_reco_artists(Json(req): Json<OauthRecoReq>) -> impl IntoResponse
2243
  let index = req.index.unwrap_or(0).to_string();
2244
  let limit = req.limit.unwrap_or(20).clamp(1, 50).to_string();
2245
  let client = reqwest::Client::builder()
 
2246
  .timeout(std::time::Duration::from_secs(15))
2247
  .build()
2248
  .unwrap();
@@ -2271,6 +2288,7 @@ async fn oauth_reco_tracks(Json(req): Json<OauthRecoReq>) -> impl IntoResponse {
2271
  let index = req.index.unwrap_or(0).to_string();
2272
  let limit = req.limit.unwrap_or(40).clamp(1, 100).to_string();
2273
  let client = reqwest::Client::builder()
 
2274
  .timeout(std::time::Duration::from_secs(15))
2275
  .build()
2276
  .unwrap();
@@ -2306,6 +2324,7 @@ async fn oauth_history(Json(req): Json<OauthHistoryReq>) -> impl IntoResponse {
2306
  let index = req.index.unwrap_or(0).to_string();
2307
  let limit = req.limit.unwrap_or(50).clamp(1, 100).to_string();
2308
  let client = reqwest::Client::builder()
 
2309
  .timeout(std::time::Duration::from_secs(15))
2310
  .build()
2311
  .unwrap();
 
192
  let url = format!("{base}/get_url");
193
 
194
  let client = reqwest::Client::builder()
195
+ .no_proxy()
196
  .timeout(std::time::Duration::from_secs(20))
197
  .build()
198
  .map_err(|_| "upstream:client".to_string())?;
 
225
 
226
  async fn public_track_duration(id: u32) -> Option<u32> {
227
  let client = reqwest::Client::builder()
228
+ .no_proxy()
229
  .timeout(std::time::Duration::from_secs(10))
230
  .build()
231
  .ok()?;
 
332
  }
333
 
334
  let client = reqwest::Client::builder()
335
+ .no_proxy()
336
  .timeout(std::time::Duration::from_secs(60))
337
  .build()
338
  .unwrap();
 
459
 
460
  let duration = public_track_duration(q.id).await.unwrap_or(0);
461
  let http = reqwest::Client::builder()
462
+ .no_proxy()
463
  .timeout(std::time::Duration::from_secs(15))
464
  .build()
465
  .unwrap();
 
624
  .and_then(parse_range_header);
625
 
626
  let http = reqwest::Client::builder()
627
+ .no_proxy()
628
  .timeout(std::time::Duration::from_secs(60))
629
  .build()
630
  .unwrap();
 
1167
  let url_deezer = "https://www.deezer.com".parse::<Url>().unwrap();
1168
  jar.add_cookie_str("comeback=1; Domain=.deezer.com", &url_deezer);
1169
  let client = reqwest::Client::builder()
1170
+ .no_proxy()
1171
  .cookie_provider(jar.clone())
1172
  .timeout(std::time::Duration::from_secs(15))
1173
  .build()
 
1593
  let url_deezer = "https://www.deezer.com".parse::<Url>().unwrap();
1594
  jar.add_cookie_str("comeback=1; Domain=.deezer.com", &url_deezer);
1595
  let client = reqwest::Client::builder()
1596
+ .no_proxy()
1597
  .cookie_provider(jar.clone())
1598
  .timeout(std::time::Duration::from_secs(20))
1599
  .build()
 
1744
  return json_error(StatusCode::BAD_REQUEST, "access_token required");
1745
  }
1746
  let client = reqwest::Client::builder()
1747
+ .no_proxy()
1748
  .timeout(std::time::Duration::from_secs(15))
1749
  .build()
1750
  .unwrap();
1751
+ .unwrap();
1752
  match api_deezer_get(&client, "/user/me", &token, &[]).await {
1753
  Ok(v) => (StatusCode::OK, Json(v)).into_response(),
1754
  Err(e) => json_error(StatusCode::SERVICE_UNAVAILABLE, e),
 
1770
  let index = req.index.unwrap_or(0).to_string();
1771
  let limit = req.limit.unwrap_or(50).to_string();
1772
  let client = reqwest::Client::builder()
1773
+ .no_proxy()
1774
  .timeout(std::time::Duration::from_secs(15))
1775
  .build()
1776
  .unwrap();
1777
+ .unwrap();
1778
  let me = match api_deezer_get(&client, "/user/me", &token, &[]).await {
1779
  Ok(v) => v,
1780
  Err(e) => return json_error(StatusCode::SERVICE_UNAVAILABLE, e),
 
1810
  let index = req.index.unwrap_or(0).to_string();
1811
  let limit = req.limit.unwrap_or(100).to_string();
1812
  let client = reqwest::Client::builder()
1813
+ .no_proxy()
1814
  .timeout(std::time::Duration::from_secs(15))
1815
  .build()
1816
  .unwrap();
1817
+ .unwrap();
1818
  let path = format!("/playlist/{}/tracks", req.playlist_id);
1819
  let extra = [("index", index), ("limit", limit)];
1820
  match api_deezer_get(&client, &path, &token, &extra).await {
 
2164
  }
2165
  let limit = req.limit.unwrap_or(40).clamp(1, 100).to_string();
2166
  let client = reqwest::Client::builder()
2167
+ .no_proxy()
2168
  .timeout(std::time::Duration::from_secs(15))
2169
  .build()
2170
  .unwrap();
 
2201
  let index = req.index.unwrap_or(0).to_string();
2202
  let limit = req.limit.unwrap_or(20).clamp(1, 50).to_string();
2203
  let client = reqwest::Client::builder()
2204
+ .no_proxy()
2205
  .timeout(std::time::Duration::from_secs(15))
2206
  .build()
2207
  .unwrap();
 
2230
  let index = req.index.unwrap_or(0).to_string();
2231
  let limit = req.limit.unwrap_or(20).clamp(1, 50).to_string();
2232
  let client = reqwest::Client::builder()
2233
+ .no_proxy()
2234
  .timeout(std::time::Duration::from_secs(15))
2235
  .build()
2236
  .unwrap();
 
2259
  let index = req.index.unwrap_or(0).to_string();
2260
  let limit = req.limit.unwrap_or(20).clamp(1, 50).to_string();
2261
  let client = reqwest::Client::builder()
2262
+ .no_proxy()
2263
  .timeout(std::time::Duration::from_secs(15))
2264
  .build()
2265
  .unwrap();
 
2288
  let index = req.index.unwrap_or(0).to_string();
2289
  let limit = req.limit.unwrap_or(40).clamp(1, 100).to_string();
2290
  let client = reqwest::Client::builder()
2291
+ .no_proxy()
2292
  .timeout(std::time::Duration::from_secs(15))
2293
  .build()
2294
  .unwrap();
 
2324
  let index = req.index.unwrap_or(0).to_string();
2325
  let limit = req.limit.unwrap_or(50).clamp(1, 100).to_string();
2326
  let client = reqwest::Client::builder()
2327
+ .no_proxy()
2328
  .timeout(std::time::Duration::from_secs(15))
2329
  .build()
2330
  .unwrap();