From d009e6f88d0240221c0b33942a1073d3b7b5f5ee Mon Sep 17 00:00:00 2001 From: sarendsen Date: Wed, 15 Nov 2023 11:16:08 +0100 Subject: [PATCH] WIP --- src/models.rs | 5 ++--- src/plex_client.rs | 37 ++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/models.rs b/src/models.rs index a987485..7105f54 100644 --- a/src/models.rs +++ b/src/models.rs @@ -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 = None; @@ -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; diff --git a/src/plex_client.rs b/src/plex_client.rs index c54e97b..0e4c887 100644 --- a/src/plex_client.rs +++ b/src/plex_client.rs @@ -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(), @@ -390,7 +390,6 @@ impl PlexClient { res.status() ))); } - // if res.status() == 500 { // return Err(salvo::http::StatusError::); // }