From 9c8ee8647ab52a4b0471604fbca4dfaff52e5b28 Mon Sep 17 00:00:00 2001 From: lostb1t Date: Sat, 7 Sep 2024 11:38:03 +0200 Subject: [PATCH] fix: hero images for web --- Makefile | 1 - src/routes.rs | 12 +++++++++--- src/transform/media_style.rs | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 995faf3..5970c7b 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,6 @@ run: RUST_BACKTRACE=0 \ RUST_LOG="info,replex=debug" \ REPLEX_NTF_WATCHLIST_FORCE=0 \ - RUSTFLAGS=-Awarnings \ cargo watch -w src -x run fix: diff --git a/src/routes.rs b/src/routes.rs index 8d4cd37..314b089 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -308,14 +308,20 @@ async fn resolve_local_media_path( req: &mut Request, res: &mut Response, ) { - let context: PlexContext = req.extract().await.unwrap(); + let mut context: PlexContext = req.extract().await.unwrap(); let url = req.query::("url"); if url.is_some() && url.clone().unwrap().contains("/replex/image/hero") { let uri: url::Url = url::Url::parse(url.unwrap().as_str()).unwrap(); - let uuid = uri.path_segments().unwrap().last(); + let segments = uri.path_segments().unwrap().collect::>(); + + let uuid = segments[segments.len() - 2]; + if context.token.is_none() { + context.token = Some(segments.last().unwrap().to_string()); + } + let plex_client = PlexClient::from_context(&context); - let rurl = plex_client.get_hero_art(uuid.unwrap().to_string()).await; + let rurl = plex_client.get_hero_art(uuid.to_string()).await; if rurl.is_some() { add_query_param_salvo(req, "url".to_string(), rurl.unwrap()); } diff --git a/src/transform/media_style.rs b/src/transform/media_style.rs index 1df0437..1ea244e 100644 --- a/src/transform/media_style.rs +++ b/src/transform/media_style.rs @@ -43,7 +43,7 @@ impl Transform for MediaStyleTransform { } guid = guid.replace("plex://", ""); - let cover_art = Some(format!("/replex/image/hero/{}?X-Plex-Token={}", + let cover_art = Some(format!("/replex/image/hero/{}/{}", // let cover_art = Some(format!("{}://{}/replex/image/hero/{}?X-Plex-Token={}", // match options.forwarded_proto { // Some(v) => v,