diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d35140..69679d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Setup Android NDK run: yes | sdkmanager "ndk;21.0.6113669" >/dev/null - name: Set default rust toolchain - run: rustup default 1.61.0 + run: rustup default 1.67.1 - name: Install rustfmt run: rustup component add rustfmt - name: Install clippy diff --git a/src/commonMain/rust/bridge/action.rs b/src/commonMain/rust/bridge/action.rs index 1aaf1e8..82caef5 100644 --- a/src/commonMain/rust/bridge/action.rs +++ b/src/commonMain/rust/bridge/action.rs @@ -159,9 +159,9 @@ impl FromProtobuf for runtime::Action { } } Some(runtime::action::Type::Player(action_player)) => match &action_player.args { - Some(action_player::Args::VideoParamsChanged(video_params_changed)) => { + Some(action_player::Args::VideoParamsChanged(video_params)) => { Action::Player(ActionPlayer::VideoParamsChanged { - video_params: video_params_changed.video_param.from_protobuf(), + video_params: Some(video_params.from_protobuf()), }) } Some(action_player::Args::TimeChanged(item_state)) => { diff --git a/src/commonMain/rust/bridge/continue_watching_item.rs b/src/commonMain/rust/bridge/continue_watching_item.rs deleted file mode 100644 index ddf424b..0000000 --- a/src/commonMain/rust/bridge/continue_watching_item.rs +++ /dev/null @@ -1,60 +0,0 @@ -use stremio_core::deep_links::LibraryItemDeepLinks; -use stremio_core::models::continue_watching_preview::Item; -use stremio_core::types::profile::Settings; -use stremio_core::types::streams::StreamsItem; -use url::Url; - -use crate::protobuf::stremio::core::models; -use crate::protobuf::stremio::core::types; - -use super::ToProtobuf; - -impl ToProtobuf, Option<&Url>, &Settings)> - for Item -{ - fn to_protobuf( - &self, - (streams_item, streaming_server_url, settings): &( - Option<&StreamsItem>, - Option<&Url>, - &Settings, - ), - ) -> models::ContinueWatchingItem { - let deep_links = LibraryItemDeepLinks::from(( - &self.library_item, - *streams_item, - *streaming_server_url, - *settings, - )); - 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/event.rs b/src/commonMain/rust/bridge/event.rs index 28ff3d4..0441b0b 100644 --- a/src/commonMain/rust/bridge/event.rs +++ b/src/commonMain/rust/bridge/event.rs @@ -186,7 +186,7 @@ impl ToProtobuf for Event { impl ToProtobuf for RuntimeEvent { fn to_protobuf(&self, _args: &()) -> runtime::RuntimeEvent { let event = match self { - RuntimeEvent::NewState(fields) => { + RuntimeEvent::NewState(fields, ..) => { runtime::runtime_event::Event::NewState(runtime::runtime_event::NewState { fields: fields .to_protobuf(&()) diff --git a/src/commonMain/rust/bridge/library_item.rs b/src/commonMain/rust/bridge/library_item.rs index 3cb868f..e92aa62 100644 --- a/src/commonMain/rust/bridge/library_item.rs +++ b/src/commonMain/rust/bridge/library_item.rs @@ -1,15 +1,22 @@ use stremio_core::deep_links::LibraryItemDeepLinks; +use stremio_core::models::ctx::Ctx; use stremio_core::types::library::LibraryItem; -use stremio_core::types::profile::Settings; -use stremio_core::types::streams::StreamsItem; -use url::Url; use crate::bridge::ToProtobuf; use crate::protobuf::stremio::core::types; -impl ToProtobuf, Option<&Url>, &Settings)> for LibraryItem { - fn to_protobuf(&self, args: &(Option<&StreamsItem>, Option<&Url>, &Settings)) -> types::LibraryItem { - let deep_links = LibraryItemDeepLinks::from((self, args.0, args.1, args.2)); +impl ToProtobuf for LibraryItem { + fn to_protobuf(&self, ctx: &Ctx) -> types::LibraryItem { + let notifications = ctx + .notifications + .items + .get(&self.id) + .map(|notifs| notifs.len()) + .unwrap_or_default(); + let settings = &ctx.profile.settings; + let streaming_server_url = &settings.streaming_server_url; + let deep_links = + LibraryItemDeepLinks::from((self, None, Some(streaming_server_url), settings)); types::LibraryItem { id: self.id.to_string(), r#type: self.r#type.to_string(), @@ -27,12 +34,9 @@ impl ToProtobuf, Option<&Url>, &Settin meta_details_streams: deep_links.meta_details_streams, player: deep_links.player, }, - progress: if self.state.time_offset > 0 && self.state.duration > 0 { - Some(self.state.time_offset as f64 / self.state.duration as f64) - } else { - None - }, + progress: self.progress(), watched: self.state.times_watched > 0, + notifications: notifications as u64, } } } diff --git a/src/commonMain/rust/bridge/mod.rs b/src/commonMain/rust/bridge/mod.rs index 7c2ea6a..0755d13 100644 --- a/src/commonMain/rust/bridge/mod.rs +++ b/src/commonMain/rust/bridge/mod.rs @@ -7,9 +7,6 @@ pub use android_model_field::*; mod auth_request; pub use auth_request::*; -mod continue_watching_item; -pub use continue_watching_item::*; - 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 c95c9d2..3afe78a 100644 --- a/src/commonMain/rust/model/fields/continue_watching_preview.rs +++ b/src/commonMain/rust/model/fields/continue_watching_preview.rs @@ -1,12 +1,19 @@ -use stremio_core::models::continue_watching_preview::ContinueWatchingPreview; +use stremio_core::models::continue_watching_preview::{ContinueWatchingPreview, Item}; +use stremio_core::models::ctx::Ctx; use crate::bridge::ToProtobuf; -use crate::protobuf::stremio::core::models; +use crate::protobuf::stremio::core::{models, types}; -impl ToProtobuf for ContinueWatchingPreview { - fn to_protobuf(&self, _args: &()) -> models::ContinueWatchingPreview { +impl ToProtobuf for Item { + fn to_protobuf(&self, ctx: &Ctx) -> types::LibraryItem { + self.library_item.to_protobuf(ctx) + } +} + +impl ToProtobuf for ContinueWatchingPreview { + fn to_protobuf(&self, ctx: &Ctx) -> models::ContinueWatchingPreview { models::ContinueWatchingPreview { - items: self.items.to_protobuf(todo!()), + library_items: self.items.to_protobuf(ctx), } } } diff --git a/src/commonMain/rust/model/fields/library.rs b/src/commonMain/rust/model/fields/library.rs index f8646c4..f9c94c4 100644 --- a/src/commonMain/rust/model/fields/library.rs +++ b/src/commonMain/rust/model/fields/library.rs @@ -1,6 +1,7 @@ use std::cmp; use std::convert::TryFrom; use std::num::NonZeroUsize; +use stremio_core::models::ctx::Ctx; use stremio_core::models::library_with_filters::{ LibraryRequest, LibraryRequestPage, LibraryWithFilters, Selectable, SelectablePage, @@ -110,12 +111,12 @@ impl ToProtobuf for Selectable { } } -impl ToProtobuf for LibraryWithFilters { - fn to_protobuf(&self, _args: &()) -> models::LibraryWithFilters { +impl ToProtobuf for LibraryWithFilters { + fn to_protobuf(&self, ctx: &Ctx) -> models::LibraryWithFilters { models::LibraryWithFilters { selected: self.selected.to_protobuf(&()), selectable: self.selectable.to_protobuf(&()), - catalog: self.catalog.to_protobuf(todo!("Args")), + catalog: self.catalog.to_protobuf(ctx), } } } diff --git a/src/commonMain/rust/model/fields/library_by_type.rs b/src/commonMain/rust/model/fields/library_by_type.rs index a4a86fc..6bb21d7 100644 --- a/src/commonMain/rust/model/fields/library_by_type.rs +++ b/src/commonMain/rust/model/fields/library_by_type.rs @@ -1,3 +1,4 @@ +use stremio_core::models::ctx::Ctx; use stremio_core::models::library_by_type::{ Catalog, LibraryByType, Selectable, SelectableSort, Selected, }; @@ -42,24 +43,24 @@ impl ToProtobuf for Selectable { } } -impl ToProtobuf for Catalog { - fn to_protobuf(&self, _args: &()) -> models::LibraryCatalog { +impl ToProtobuf for Catalog { + fn to_protobuf(&self, ctx: &Ctx) -> models::LibraryCatalog { let items = self .iter() .flatten() - .map(|item| item.to_protobuf(todo!("Args"))) + .map(|item| item.to_protobuf(ctx)) .collect::>(); let r#type = items.first().map(|item| item.r#type.to_owned()); models::LibraryCatalog { r#type, items } } } -impl ToProtobuf for LibraryByType { - fn to_protobuf(&self, _args: &()) -> models::LibraryByType { +impl ToProtobuf for LibraryByType { + fn to_protobuf(&self, ctx: &Ctx) -> models::LibraryByType { models::LibraryByType { selected: self.selected.to_protobuf(&()), selectable: self.selectable.to_protobuf(&()), - catalogs: self.catalogs.to_protobuf(&()), + catalogs: self.catalogs.to_protobuf(ctx), } } } diff --git a/src/commonMain/rust/model/fields/meta_details.rs b/src/commonMain/rust/model/fields/meta_details.rs index 72aa1c2..960f12f 100644 --- a/src/commonMain/rust/model/fields/meta_details.rs +++ b/src/commonMain/rust/model/fields/meta_details.rs @@ -17,7 +17,7 @@ impl FromProtobuf for models::meta_details::Selected { Selected { meta_path: self.meta_path.from_protobuf(), stream_path: self.stream_path.from_protobuf(), - guess_stream: self.guess_stream, + guess_stream: self.guess_stream_path, } } } @@ -27,7 +27,7 @@ impl ToProtobuf for Selected { models::meta_details::Selected { meta_path: self.meta_path.to_protobuf(&()), stream_path: self.stream_path.to_protobuf(&()), - guess_stream: self.guess_stream, + guess_stream_path: self.guess_stream, } } } diff --git a/src/commonMain/rust/model/fields/player.rs b/src/commonMain/rust/model/fields/player.rs index 400b9ff..e677a14 100644 --- a/src/commonMain/rust/model/fields/player.rs +++ b/src/commonMain/rust/model/fields/player.rs @@ -1,6 +1,5 @@ use stremio_core::models::ctx::Ctx; use stremio_core::models::player::{Player, Selected, VideoParams}; -use stremio_core::types::streams::StreamsItemKey; use crate::bridge::{FromProtobuf, ToProtobuf}; use crate::protobuf::stremio::core::models; @@ -56,19 +55,6 @@ impl ToProtobuf for Selected { impl ToProtobuf for Player { fn to_protobuf(&self, ctx: &Ctx) -> models::Player { - - - // let stream_item = ctx.streams.items.get(StreamsItemKey { meta_id: self.selected.map(|selected| selected.meta_request.and_then) ), video_id: () }); - - // let streaming_server_url = match ctx.streaming_server.base_url.clone() { - // Loadable::Ready(url) => Some(url), - // _ => None, - // }; - // let meta_item_id = self.meta_item.map(|meta_item| meta_item.request.path.id.clone()); - // let meta_item_id = self.vi.and_then(|meta_item| meta_item.request.path.id.clone()); - // let stream_item = ctx.streams.items.get(StreamsItemKey { meta_id: self., video_id: () }); - - models::Player { selected: self.selected.to_protobuf(ctx), video_params: self.video_params.to_protobuf(&()), @@ -84,7 +70,7 @@ impl ToProtobuf for Player { None, )), series_info: self.series_info.to_protobuf(&()), - library_item: todo!(), //self.library_item.to_protobuf(&()), + library_item: self.library_item.to_protobuf(ctx), } } } diff --git a/src/commonMain/rust/model/model.rs b/src/commonMain/rust/model/model.rs index ed20f4e..e2eec01 100644 --- a/src/commonMain/rust/model/model.rs +++ b/src/commonMain/rust/model/model.rs @@ -92,11 +92,11 @@ impl AndroidModel { AndroidModelField::AuthLink => self.auth_link.to_protobuf(&()).encode_to_vec(), AndroidModelField::ContinueWatchingPreview => self .continue_watching_preview - .to_protobuf(&()) + .to_protobuf(&self.ctx) .encode_to_vec(), - AndroidModelField::Library => self.library.to_protobuf(&()).encode_to_vec(), + AndroidModelField::Library => self.library.to_protobuf(&self.ctx).encode_to_vec(), AndroidModelField::LibraryByType => { - self.library_by_type.to_protobuf(&()).encode_to_vec() + self.library_by_type.to_protobuf(&self.ctx).encode_to_vec() } AndroidModelField::Board => self.board.to_protobuf(&self.ctx).encode_to_vec(), AndroidModelField::Search => self.search.to_protobuf(&self.ctx).encode_to_vec(), @@ -114,4 +114,4 @@ impl AndroidModel { AndroidModelField::Player => self.player.to_protobuf(&self.ctx).encode_to_vec(), } } -} \ No newline at end of file +} diff --git a/src/main/proto/stremio/core/models/continue_watching_preview.proto b/src/main/proto/stremio/core/models/continue_watching_preview.proto index 1b54017..c98f373 100644 --- a/src/main/proto/stremio/core/models/continue_watching_preview.proto +++ b/src/main/proto/stremio/core/models/continue_watching_preview.proto @@ -6,22 +6,6 @@ option java_package = "com.stremio.core.models"; import "stremio/core/types/library.proto"; -import "stremio/core/types/meta_item.proto"; - -message ContinueWatchingItem { - required string id = 1; - required string type = 2; - required string name = 3; - optional string poster = 4; - required stremio.core.types.PosterShape poster_shape = 5; - required stremio.core.types.LibraryItemState state = 6; - required stremio.core.types.MetaItemBehaviorHints behavior_hints = 7; - required stremio.core.types.MetaItemDeepLinks deep_links = 8; - optional double progress = 9; - required bool watched = 10; - required uint64 notifications = 11; -} - message ContinueWatchingPreview { - repeated ContinueWatchingItem items = 1; + repeated stremio.core.types.LibraryItem library_items = 1; } \ No newline at end of file diff --git a/src/main/proto/stremio/core/models/meta_details.proto b/src/main/proto/stremio/core/models/meta_details.proto index 0f3cfc0..599495a 100644 --- a/src/main/proto/stremio/core/models/meta_details.proto +++ b/src/main/proto/stremio/core/models/meta_details.proto @@ -18,7 +18,7 @@ message MetaDetails { message Selected { required stremio.core.types.ResourcePath meta_path = 1; optional stremio.core.types.ResourcePath stream_path = 2; - required bool guess_stream = 3; + required bool guess_stream_path = 3; } } diff --git a/src/main/proto/stremio/core/runtime/action_player.proto b/src/main/proto/stremio/core/runtime/action_player.proto index e0d4989..93a0c73 100644 --- a/src/main/proto/stremio/core/runtime/action_player.proto +++ b/src/main/proto/stremio/core/runtime/action_player.proto @@ -5,12 +5,11 @@ package stremio.core.runtime; option java_package = "com.stremio.core.runtime.msg"; import "google/protobuf/empty.proto"; - import "stremio/core/models/player.proto"; message ActionPlayer { oneof args { - VideoParamsChanged video_params_changed = 1; + stremio.core.models.Player.VideoParams video_params_changed = 1; PlayerItemState time_changed = 2; bool paused_changed = 3; google.protobuf.Empty ended = 4; @@ -21,8 +20,4 @@ message ActionPlayer { required uint64 duration = 2; required string device = 3; } - - message VideoParamsChanged { - optional stremio.core.models.Player.VideoParams video_param = 1; - } } \ No newline at end of file diff --git a/src/main/proto/stremio/core/types/library.proto b/src/main/proto/stremio/core/types/library.proto index e60f027..469248b 100644 --- a/src/main/proto/stremio/core/types/library.proto +++ b/src/main/proto/stremio/core/types/library.proto @@ -15,8 +15,9 @@ message LibraryItem { required LibraryItemState state = 6; required MetaItemBehaviorHints behavior_hints = 7; required MetaItemDeepLinks deep_links = 8; - optional double progress = 9; + required double progress = 9; required bool watched = 10; + required uint64 notifications = 11; } message LibraryItemState {