From 81758f66f148ca7e26bf202266f7c600615c5b22 Mon Sep 17 00:00:00 2001 From: Radiicall Date: Sat, 7 Oct 2023 21:19:53 +0200 Subject: [PATCH] Fixed content that doesnt have images --- src/services/jellyfin.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/services/jellyfin.rs b/src/services/jellyfin.rs index 919c1e2..110f1c5 100644 --- a/src/services/jellyfin.rs +++ b/src/services/jellyfin.rs @@ -140,7 +140,7 @@ impl Content { .and_then(|images| images.enable_images) .unwrap_or(false) { - image_url = Content::image(&config.jellyfin.url, content.item_id.clone()).await; + image_url = Content::image(&config.jellyfin.url, content.item_id.clone()).await.unwrap_or(String::from("")); } content.external_services(ExternalServices::get(now_playing_item).await); @@ -344,12 +344,18 @@ impl Content { state } - async fn image(url: &str, item_id: String) -> String { - format!( + async fn image(url: &str, item_id: String) -> Result { + let img = format!( "{}/Items/{}/Images/Primary", url.trim_end_matches('/'), item_id - ) + ); + + if reqwest::get(&img).await?.text().await.unwrap_or(String::from("_")).contains("does not have an image of type Primary") { + Ok(String::from("")) + } else { + Ok(img) + } } fn get_genres(npi: &Value) -> Option {