Skip to content

Commit

Permalink
fix!: upcoming state for videos
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Mar 5, 2024
1 parent ee2dafc commit 549a2c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
10 changes: 3 additions & 7 deletions src/model/serialize_meta_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<f64>,
Expand Down Expand Up @@ -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()
Expand Down
18 changes: 5 additions & 13 deletions src/model/serialize_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>,
pub scheduled: bool,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 549a2c5

Please sign in to comment.