Skip to content
This repository was archived by the owner on Apr 12, 2025. It is now read-only.

Commit 1a73cd1

Browse files
committed
fix: some more debugging
1 parent c3d5b1f commit 1a73cd1

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ run:
3333
REPLEX_ENABLE_CONSOLE=0 \
3434
REPLEX_CACHE_TTL=0 \
3535
REPLEX_HUB_RESTRICTIONS=1 \
36-
RUST_LOG="info,replex=info" \
36+
RUST_LOG="debug,replex=debug" \
3737
REPLEX_NTF_WATCHLIST_FORCE=0 \
3838
RUSTFLAGS=-Awarnings \
3939
cargo watch -w src -x run

src/plex_client.rs

+8
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,14 @@ impl PlexClient {
274274
self,
275275
uuid: String,
276276
) -> Option<String> {
277+
//tracing::debug!(uuid = uuid, "Loading hero art from plex");
277278
let cache_key = format!("{}:hero_art", uuid);
278279

279280
let cached_result: Option<Option<String>> =
280281
GLOBAL_CACHE.get(cache_key.as_str()).await;
281282

282283
if cached_result.is_some() {
284+
//tracing::debug!("Returning cached version");
283285
return cached_result.unwrap();
284286
}
285287

@@ -307,8 +309,14 @@ impl PlexClient {
307309
}
308310
}
309311

312+
if image.is_none() {
313+
tracing::warn!(uuid = uuid, "No hero image found on plex");
314+
}
315+
310316
image.as_ref()?; // dont return and dont cache, let us just retry next time.
311317

318+
//tracing::debug!("Hero image found");
319+
312320
let cache_expiry = crate::cache::Expiration::Month;
313321
let _ = GLOBAL_CACHE
314322
.insert(cache_key, image.clone(), cache_expiry)

src/routes.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ pub fn route() -> Router {
133133
.hoop(proxy_for_transform)
134134
.get(transform_hubs_response),
135135
)
136+
.push(
137+
Router::new()
138+
.path("/replex/test_proxy/<**rest>")
139+
.goal(test_proxy_request),
140+
)
136141
.push(
137142
Router::new()
138143
.path("/replex/image/hero/<type>/<uuid>")
@@ -184,11 +189,22 @@ async fn proxy_request(
184189
depot: &mut Depot,
185190
ctrl: &mut FlowCtrl,
186191
) {
187-
let config: Config = Config::dynamic(req).extract().unwrap();
188192
let proxy = default_proxy();
189193
proxy.handle(req, depot, res, ctrl).await;
190194
}
191195

196+
#[handler]
197+
async fn test_proxy_request(
198+
req: &mut Request,
199+
res: &mut Response,
200+
depot: &mut Depot,
201+
ctrl: &mut FlowCtrl,
202+
) {
203+
dbg!("yo");
204+
let proxy = test_proxy("https://webhook.site".to_string());
205+
proxy.handle(req, depot, res, ctrl).await;
206+
}
207+
192208
#[handler]
193209
async fn proxy_for_transform(
194210
req: &mut Request,

src/utils.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn default_url_query_getter(
4949
}
5050
}
5151

52-
52+
// Proxy to plex instance
5353
pub fn default_proxy() -> Proxy<String, ReqwestClient> {
5454
let config: Config = Config::figment().extract().unwrap();
5555
let mut proxy = Proxy::new(
@@ -64,8 +64,6 @@ pub fn default_proxy() -> Proxy<String, ReqwestClient> {
6464
proxy
6565
}
6666

67-
68-
6967
pub fn proxy(upstream: String) -> Proxy<String, ReqwestClient> {
7068
let mut proxy = Proxy::new(
7169
upstream,
@@ -79,6 +77,17 @@ pub fn proxy(upstream: String) -> Proxy<String, ReqwestClient> {
7977
proxy
8078
}
8179

80+
pub fn test_proxy(upstream: String) -> Proxy<String, ReqwestClient> {
81+
let mut proxy = Proxy::new(
82+
upstream,
83+
ReqwestClient::new(reqwest::Client::builder()
84+
.build()
85+
.unwrap())
86+
);
87+
88+
proxy
89+
}
90+
8291
pub fn get_collection_id_from_child_path(path: String) -> i32 {
8392
let mut path = path.replace("/library/collections/", "");
8493
path = path.replace("/children", "");

0 commit comments

Comments
 (0)