Skip to content

Commit

Permalink
fix: add token to images
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Jul 11, 2024
1 parent 7bee0d2 commit e63c87a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn route() -> Router {
)
.push(
Router::new()
.path("/image/hero/<type>/<uuid>")
.path("/image/hero/<type>/<uuid>/<**token>")
// .path("/image/hero.jpg")
.get(hero_image)
//.get(proxy_request),
Expand Down Expand Up @@ -384,11 +384,16 @@ pub async fn hero_image(
ctrl: &mut FlowCtrl,
depot: &mut Depot,
) {
let params: PlexContext = req.extract().await.unwrap();
let plex_client = PlexClient::from_request(req, params.clone());
let mut params: PlexContext = req.extract().await.unwrap();
// dbg!(&req);
let t = req.param::<String>("type").unwrap();
let uuid = req.param::<String>("uuid").unwrap();
let token = req.param::<String>("**token");
dbg!(&token);
if token.is_some() {
params.token = token;
}
let plex_client = PlexClient::from_request(req, params.clone());
let url = plex_client.get_hero_art(uuid).await;
if url.is_none() {
res.status_code(StatusCode::NOT_FOUND);
Expand Down
6 changes: 5 additions & 1 deletion src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,11 @@ impl Transform for MediaStyleTransform {
.replace("plex://", "");

//let cover_art = item.get_hero_art(plex_client).await;
let cover_art = Some(format!("{}/image/hero/{}", options.host.clone().unwrap(), guid));
let cover_art = Some(format!("{}/image/hero/{}/{}",
options.host.clone().unwrap(),
guid,
options.token.clone().unwrap()
));
//dbg!(&options);
if cover_art.is_some() {
// c.art = art.clone();
Expand Down

0 comments on commit e63c87a

Please sign in to comment.