From cfdb599db1e82566fc61de88db0326637d6cc105 Mon Sep 17 00:00:00 2001 From: lostb1t Date: Thu, 18 Jul 2024 20:46:49 +0200 Subject: [PATCH] fix: image resolver --- src/plex_client.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/plex_client.rs b/src/plex_client.rs index cd93da2..93c2ef0 100644 --- a/src/plex_client.rs +++ b/src/plex_client.rs @@ -91,7 +91,7 @@ impl PlexClient { //let mut headers = req.headers_mut().to_owned(); //let target_uri: url::Url = url::Url::parse(self.host.as_str()).unwrap(); //let target_host = target_uri.host().unwrap().to_string().clone(); - dbg!(&req); + //dbg!(&req); //headers.remove(ACCEPT); // remove accept as we always do json request //headers.insert( // http::header::HOST, @@ -345,19 +345,19 @@ impl PlexClient { //endpoint is buggy, if llex has a cached version then it doesnt need a plex token // but if not cached then a server admin token is needed let mut token = config.token.clone(); - if token.is_none() { - token = Some(self.context.token.clone().unwrap()); + if token.is_some() { + headers.insert( + "X-Plex-Token", + header::HeaderValue::from_str(token.unwrap().as_str()).unwrap(), + ); }; - headers.insert( - "X-Plex-Token", - header::HeaderValue::from_str(token.unwrap().as_str()).unwrap(), - ); headers.insert( "Accept", header::HeaderValue::from_static("application/json"), ); *req.headers_mut() = headers; + dbg!(&req); let res = self.http_client.execute(req).await.map_err(Error::other)?; @@ -438,10 +438,15 @@ impl PlexClient { ACCEPT, header::HeaderValue::from_static("application/json"), ); - headers.insert( - http::header::HOST, - header::HeaderValue::from_str(&target_host).unwrap(), - ); + + + headers.insert(ACCEPT_LANGUAGE, "en-US".parse().unwrap()); + + + //headers.insert( + // http::header::HOST, + // header::HeaderValue::from_str(&target_host).unwrap(), + //); Self { http_client: reqwest_middleware::ClientBuilder::new(