diff --git a/src/commonMain/rust/bridge/action.rs b/src/commonMain/rust/bridge/action.rs index ee49ea0..a6c8eda 100644 --- a/src/commonMain/rust/bridge/action.rs +++ b/src/commonMain/rust/bridge/action.rs @@ -109,7 +109,7 @@ impl FromProtobuf for runtime::Action { } Some(action_meta_details::Args::MarkVideoAsWatched(video_state)) => { Action::MetaDetails(ActionMetaDetails::MarkVideoAsWatched( - video_state.video_id.to_owned(), + video_state.video.from_protobuf(), video_state.is_watched, )) } diff --git a/src/commonMain/rust/bridge/continue_watching_preview.rs b/src/commonMain/rust/bridge/continue_watching_preview.rs new file mode 100644 index 0000000..5669bd2 --- /dev/null +++ b/src/commonMain/rust/bridge/continue_watching_preview.rs @@ -0,0 +1,43 @@ +use stremio_core::deep_links::LibraryItemDeepLinks; +use stremio_core::models::continue_watching_preview::Item; + +use crate::protobuf::stremio::core::models; +use crate::protobuf::stremio::core::types; + +use super::ToProtobuf; + +impl ToProtobuf for Item { + fn to_protobuf(&self, _args: &()) -> models::ContinueWatchingItem { + let deep_links = LibraryItemDeepLinks::from(&self.library_item); + models::ContinueWatchingItem { + id: self.library_item.id.to_string(), + r#type: self.library_item.r#type.to_string(), + name: self.library_item.name.to_string(), + poster: self.library_item.poster.to_protobuf(&()), + poster_shape: self.library_item.poster_shape.to_protobuf(&()) as i32, + state: types::LibraryItemState { + time_offset: self.library_item.state.time_offset, + duration: self.library_item.state.duration, + video_id: self.library_item.state.video_id.clone(), + }, + behavior_hints: self.library_item.behavior_hints.to_protobuf(&()), + deep_links: types::MetaItemDeepLinks { + meta_details_videos: deep_links.meta_details_videos, + meta_details_streams: deep_links.meta_details_streams, + player: deep_links.player, + }, + progress: if self.library_item.state.time_offset > 0 + && self.library_item.state.duration > 0 + { + Some( + self.library_item.state.time_offset as f64 + / self.library_item.state.duration as f64, + ) + } else { + None + }, + watched: self.library_item.state.times_watched > 0, + notifications: self.notifications as u64, + } + } +} diff --git a/src/commonMain/rust/bridge/mod.rs b/src/commonMain/rust/bridge/mod.rs index 0755d13..6802a87 100644 --- a/src/commonMain/rust/bridge/mod.rs +++ b/src/commonMain/rust/bridge/mod.rs @@ -7,6 +7,9 @@ pub use android_model_field::*; mod auth_request; pub use auth_request::*; +mod continue_watching_preview; +pub use continue_watching_preview::*; + mod date; pub use date::*; diff --git a/src/commonMain/rust/model/fields/continue_watching_preview.rs b/src/commonMain/rust/model/fields/continue_watching_preview.rs index baaad17..01dbd87 100644 --- a/src/commonMain/rust/model/fields/continue_watching_preview.rs +++ b/src/commonMain/rust/model/fields/continue_watching_preview.rs @@ -6,7 +6,7 @@ use crate::protobuf::stremio::core::models; impl ToProtobuf for ContinueWatchingPreview { fn to_protobuf(&self, _args: &()) -> models::ContinueWatchingPreview { models::ContinueWatchingPreview { - library_items: self.library_items.to_protobuf(&()), + items: self.items.to_protobuf(&()), } } } diff --git a/src/commonMain/rust/model/fields/meta_details.rs b/src/commonMain/rust/model/fields/meta_details.rs index ec1b0bc..d9e308e 100644 --- a/src/commonMain/rust/model/fields/meta_details.rs +++ b/src/commonMain/rust/model/fields/meta_details.rs @@ -39,6 +39,15 @@ impl ToProtobuf for SeriesInfo { } } +impl FromProtobuf for types::video::SeriesInfo { + fn from_protobuf(&self) -> SeriesInfo { + SeriesInfo { + season: self.season.unsigned_abs() as u32, + episode: self.episode.unsigned_abs() as u32, + } + } +} + impl ToProtobuf< types::Video, @@ -80,6 +89,23 @@ impl } } +impl FromProtobuf