From 549a2c5cf2dbc11ff37d953215bf04e46ed2c716 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 5 Mar 2024 18:31:36 +0100 Subject: [PATCH] fix!: upcoming state for videos --- src/model/serialize_meta_details.rs | 10 +++------- src/model/serialize_player.rs | 18 +++++------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/model/serialize_meta_details.rs b/src/model/serialize_meta_details.rs index 1bf00f4..4d0e0c5 100644 --- a/src/model/serialize_meta_details.rs +++ b/src/model/serialize_meta_details.rs @@ -50,7 +50,7 @@ mod model { pub struct Video<'a> { #[serde(flatten)] pub video: &'a stremio_core::types::resource::Video, - pub upcomming: bool, + pub upcoming: bool, pub watched: bool, // Watch progress percentage pub progress: Option, @@ -150,12 +150,8 @@ pub fn serialize_meta_details( .iter() .map(|video| model::Video { video, - upcomming: meta_item.preview.behavior_hints.has_scheduled_videos - && meta_item - .preview - .released - .map(|released| released > WebEnv::now()) - .unwrap_or(true), + upcoming: meta_item.preview.behavior_hints.has_scheduled_videos + && video.released > Some(WebEnv::now()), watched: meta_details .watched .as_ref() diff --git a/src/model/serialize_player.rs b/src/model/serialize_player.rs index da9181f..1e9adf9 100644 --- a/src/model/serialize_player.rs +++ b/src/model/serialize_player.rs @@ -47,7 +47,7 @@ mod model { pub struct Video<'a> { #[serde(flatten)] pub video: &'a stremio_core::types::resource::Video, - pub upcomming: bool, + pub upcoming: bool, pub watched: bool, pub progress: Option, pub scheduled: bool, @@ -137,12 +137,8 @@ pub fn serialize_player(player: &Player, ctx: &Ctx, streaming_server: &Streaming .iter() .map(|video| model::Video { video, - upcomming: meta_item.preview.behavior_hints.has_scheduled_videos - && meta_item - .preview - .released - .map(|released| released > WebEnv::now()) - .unwrap_or(true), + upcoming: meta_item.preview.behavior_hints.has_scheduled_videos + && video.released > Some(WebEnv::now()), watched: false, // TODO use library progress: None, // TODO use library, scheduled: meta_item.preview.behavior_hints.has_scheduled_videos, @@ -193,7 +189,7 @@ pub fn serialize_player(player: &Player, ctx: &Ctx, streaming_server: &Streaming .zip(player.next_video.as_ref()) .map(|(request, video)| model::Video { video, - upcomming: player + upcoming: player .meta_item .as_ref() .and_then(|meta_item| match meta_item { @@ -205,11 +201,7 @@ pub fn serialize_player(player: &Player, ctx: &Ctx, streaming_server: &Streaming }) .map(|meta_item| { meta_item.preview.behavior_hints.has_scheduled_videos - && meta_item - .preview - .released - .map(|released| released > WebEnv::now()) - .unwrap_or(true) + && video.released > Some(WebEnv::now()) }) .unwrap_or_default(), watched: false, // TODO use library