Skip to content

Commit 83d9600

Browse files
committed
fix: plex token
1 parent 3ba42e9 commit 83d9600

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

src/models.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,24 @@ pub struct PlexContext {
132132
pub screen_resolution: Vec<Resolution>,
133133
#[salvo(extract(rename = "X-Plex-Device-Screen-Resolution"))]
134134
pub screen_resolution_original: Option<String>,
135-
#[salvo(extract(rename = "x-plex-client-capabilities"))]
135+
#[salvo(extract(rename = "X-Plex-Client-Capabilities", alias = "x-plex-client-capabilities"))]
136136
pub client_capabilities: Option<String>,
137137
#[salvo(extract(rename = "X-Plex-Product"))]
138138
pub product: Option<String>,
139139
#[salvo(extract(rename = "X-Plex-Version"))]
140140
pub version: Option<String>,
141141
pub count: Option<i32>,
142-
#[salvo(extract(rename = "X-Plex-Client-Identifier"))]
142+
#[salvo(extract(rename = "X-Plex-Client-Identifier", alias = "x-plex-client-identifier"))]
143143
pub client_identifier: Option<String>,
144-
#[salvo(extract(rename = "X-Plex-Session-Id"))]
144+
#[salvo(extract(rename = "X-Plex-Session-Id", alias = "x-plex-session-id"))]
145145
pub session_id: Option<String>,
146-
#[salvo(extract(rename = "X-Plex-Session-Identifier"))]
146+
#[salvo(extract(rename = "X-Plex-Session-Identifier", alias = "x-plex-session-identifier"))]
147147
pub session_identifier: Option<String>,
148-
#[salvo(extract(rename = "X-Plex-Playback-Session-Id"))]
148+
#[salvo(extract(rename = "X-Plex-Playback-Session-Id", alias = "x-plex-playback-session-id"))]
149149
pub playback_session_id: Option<String>,
150150
#[salvo(extract(rename = "X-Plex-Playback-Id"))]
151151
pub playback_id: Option<String>,
152-
#[salvo(extract(rename = "X-Plex-Token"))]
152+
#[salvo(extract(rename = "X-Plex-Token", alias = "x-plex-token"))]
153153
pub token: Option<String>,
154154
#[salvo(extract(rename = "X-Plex-Platform-Version"))]
155155
pub platform_version: Option<String>,
@@ -181,11 +181,11 @@ pub struct PlexContext {
181181
pub include_advanced: bool,
182182
#[salvo(extract(rename = "X-Forwarded-For", alias = "X-Real-Ip"))]
183183
pub forwarded_for: Option<String>,
184-
#[salvo(extract(rename = "X-Forwarded-Proto"))]
184+
#[salvo(extract(rename = "X-Forwarded-Proto", alias = "x-forwared-proto"))]
185185
pub forwarded_proto: Option<String>,
186-
#[salvo(extract(rename = "x-forwarded-host"))]
186+
#[salvo(extract(rename = "X-Forwarded-Host", alias = "x-forwared-host"))]
187187
pub forwarded_host: Option<String>,
188-
#[salvo(extract(rename = "X-Forwarded-Port"))]
188+
#[salvo(extract(rename = "X-Forwarded-Port", alias = "x-forwared-port"))]
189189
pub forwarded_port: Option<String>,
190190
#[serde(default = "default_as_false", deserialize_with = "bool_from_int")]
191191
#[salvo(extract(rename = "excludeAllLeaves"))]

src/routes.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ pub fn route() -> Router {
197197
.push(
198198
Router::with_path("/photo/<colon:colon>/transcode")
199199
.hoop(fix_photo_transcode_request)
200+
// .hoop(debug)
200201
.goal(proxy_request),
201202
)
202203
.push(Router::with_path("<**rest>").goal(proxy_request));
@@ -313,6 +314,17 @@ async fn disable_related_query(
313314
add_query_param_salvo(req, "includeRelated".to_string(), "0".to_string());
314315
}
315316

317+
#[handler]
318+
async fn debug(
319+
req: &mut Request,
320+
depot: &mut Depot,
321+
res: &mut Response,
322+
ctrl: &mut FlowCtrl,
323+
) {
324+
//dbg!("tequested");
325+
dbg!(&req);
326+
}
327+
316328
#[handler]
317329
async fn ntf_watchlist_force(
318330
req: &mut Request,
@@ -391,8 +403,6 @@ pub async fn hero_image(
391403
let mut params: PlexContext = req.extract().await.unwrap();
392404
let t = req.param::<String>("type").unwrap();
393405
let uuid = req.param::<String>("uuid").unwrap();
394-
//let token = req.param::<String>("token");
395-
//dbg!(&req);
396406

397407
let plex_client = PlexClient::from_request(req, params.clone());
398408
let url = plex_client.get_hero_art(uuid).await;

src/transform.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,7 @@ impl Transform for MediaStyleTransform {
806806
}
807807
guid = guid.replace("plex://", "");
808808

809-
//let cover_art = item.get_hero_art(plex_client).await;
810-
let mut cover_art = Some(format!("{}://{}/replex/image/hero/{}?x-plex-token={}",
809+
let mut cover_art = Some(format!("{}://{}/replex/image/hero/{}?X-Plex-Token={}",
811810
match options.forwarded_proto {
812811
Some(v) => v,
813812
None => "http".to_string()
@@ -820,8 +819,7 @@ impl Transform for MediaStyleTransform {
820819
guid,
821820
options.token.clone().unwrap()
822821
));
823-
//cover_art = None;
824-
//dbg!(&cover_art);
822+
825823
if cover_art.is_some() {
826824
// c.art = art.clone();
827825
item.images = vec![Image {

0 commit comments

Comments
 (0)