Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Nov 15, 2023
1 parent 1eaab3c commit d009e6f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,7 @@ impl MetaData {
MediaContainerWrapper::default()
}
};

// let mut container = plex_client.get_provider_data(guid).await.unwrap();
let metadata = container.media_container.children_mut().get(0);
let mut image: Option<String> = None;
Expand All @@ -1305,9 +1306,7 @@ impl MetaData {
}

let mut cache_expiry = crate::cache::Expiration::Month;
if image.is_none() {
cache_expiry = crate::cache::Expiration::Day;
}
image.as_ref()?; // dont return and dont cache, let us just retry next time.
let _ = GLOBAL_CACHE
.insert(cache_key, image.clone(), cache_expiry)
.await;
Expand Down
37 changes: 18 additions & 19 deletions src/plex_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,24 +354,24 @@ impl PlexClient {
// req.set_uri(uri.try_into().unwrap());
*req.headers_mut() = headers;

let client = reqwest_middleware::ClientBuilder::new(
reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()
.unwrap(),
)
.with(RetryTransientMiddleware::new_with_policy_and_strategy(
ExponentialBackoff::builder()
.retry_bounds(
Duration::from_millis(500),
Duration::from_secs(2),
)
.build_with_max_retries(3),
Retry401,
))
.build();
let res = client.execute(req).await.map_err(Error::other)?;
// let res = Client::new().execute(req).await.map_err(Error::other)?;
// let client = reqwest_middleware::ClientBuilder::new(
// reqwest::Client::builder()
// .timeout(Duration::from_secs(30))
// .build()
// .unwrap(),
// )
// .with(RetryTransientMiddleware::new_with_policy_and_strategy(
// ExponentialBackoff::builder()
// .retry_bounds(
// Duration::from_millis(100),
// Duration::from_secs(2),
// )
// .build_with_max_retries(3),
// Retry401,
// ))
// .build();
// let res = client.execute(req).await.map_err(Error::other)?;
let res = Client::new().execute(req).await.map_err(Error::other)?;
// headers.insert(
// "X-Plex-Token",
// header::HeaderValue::from_str(self.x_plex_token.clone().as_str()).unwrap(),
Expand All @@ -390,7 +390,6 @@ impl PlexClient {
res.status()
)));
}

// if res.status() == 500 {
// return Err(salvo::http::StatusError::);
// }
Expand Down

0 comments on commit d009e6f

Please sign in to comment.