Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

[Breaking] Fix upcoming state for videos #101

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading