Skip to content

Commit

Permalink
fix: web hero art
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Sep 13, 2024
1 parent 4ed60cb commit ecbe022
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

#![allow(warnings)]
#[macro_use]
extern crate yaserde;
extern crate yaserde_derive;
Expand Down
1 change: 1 addition & 0 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub enum Platform {
Safari,
Chrome,
Roku,
Web,
#[serde(other)]
#[strum(serialize = "Generic")]
Generic,
Expand Down
24 changes: 21 additions & 3 deletions src/transform/hub_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct HubStyleTransform {

pub struct ClientHeroStyle {
pub enabled: bool,
pub include_meta: bool,
pub r#type: String,
pub style: Option<String>,
pub child_type: Option<String>,
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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") {
Expand All @@ -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()
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ecbe022

Please sign in to comment.