From ecbe02278ebdf3f35a0038e31f518f7e1464df53 Mon Sep 17 00:00:00 2001 From: lostb1t Date: Fri, 13 Sep 2024 09:14:40 +0200 Subject: [PATCH] fix: web hero art --- src/lib.rs | 2 ++ src/models.rs | 1 + src/transform/hub_style.rs | 24 +++++++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1f33025..44e7e8c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ + +#![allow(warnings)] #[macro_use] extern crate yaserde; extern crate yaserde_derive; diff --git a/src/models.rs b/src/models.rs index 7d1993a..0ac0203 100644 --- a/src/models.rs +++ b/src/models.rs @@ -74,6 +74,7 @@ pub enum Platform { Safari, Chrome, Roku, + Web, #[serde(other)] #[strum(serialize = "Generic")] Generic, diff --git a/src/transform/hub_style.rs b/src/transform/hub_style.rs index c031363..beb2080 100644 --- a/src/transform/hub_style.rs +++ b/src/transform/hub_style.rs @@ -19,6 +19,7 @@ pub struct HubStyleTransform { pub struct ClientHeroStyle { pub enabled: bool, + pub include_meta: bool, pub r#type: String, pub style: Option, pub child_type: Option, @@ -30,6 +31,7 @@ impl Default for ClientHeroStyle { fn default() -> Self { Self { enabled: true, + include_meta: true, style: Some("hero".to_string()), r#type: "mixed".to_string(), child_type: None, @@ -58,7 +60,7 @@ impl ClientHeroStyle { pub fn from_context(context: PlexContext) -> Self { // pub fn android(product: String, platform_version: String) -> Self { let product = context.product.clone().unwrap_or_default(); - let device_type = DeviceType::from_product(product); + let device_type = DeviceType::from_product(product.clone()); let platform = context.platform.clone().unwrap_or_default(); let platform_version = context.platform_version.clone().unwrap_or_default(); @@ -92,7 +94,11 @@ impl ClientHeroStyle { Platform::Ios => ClientHeroStyle::ios_style(), Platform::TvOS => ClientHeroStyle::tvos_style(), _ => { - ClientHeroStyle::default() + if product.clone().to_lowercase() == "plex web" { + ClientHeroStyle::web() + } else { + ClientHeroStyle::default() + } } // _ => { // if product.starts_with("Plex HTPC") { @@ -118,6 +124,15 @@ impl ClientHeroStyle { } } + pub fn web() -> Self { + Self { + include_meta: false, + cover_art_as_art: true, + cover_art_as_thumb: true, + ..ClientHeroStyle::default() + } + } + pub fn htpc_style() -> Self { Self { ..ClientHeroStyle::default() @@ -184,7 +199,10 @@ impl Transform for HubStyleTransform { item.style = style.style; item.r#type = style.r#type; - item.meta = Some(hero_meta()); + + if style.include_meta { + item.meta = Some(hero_meta()); + } let mut futures = FuturesOrdered::new(); // let now = Instant::now();