Skip to content

Commit

Permalink
bump core again
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Dec 2, 2023
1 parent 409dd35 commit 9e877fd
Show file tree
Hide file tree
Showing 20 changed files with 236 additions and 114 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ lto = true
opt-level = 3

[dependencies]
stremio-core = { git = "https://github.com/Stremio/stremio-core", branch = "implement-stream-state-management", features = [
stremio-core = { git = "https://github.com/Stremio/stremio-core", branch = "development", features = [
"derive",
"analytics",
"env-future-send",
] }

stremio-watched-bitfield = { git = "https://github.com/Stremio/stremio-core", branch = "implement-stream-state-management" }
stremio-watched-bitfield = { git = "https://github.com/Stremio/stremio-core", branch = "development" }
serde = "1.0.*"
serde_json = "1.0.*"
futures = "0.3.*"
Expand Down
14 changes: 14 additions & 0 deletions src/commonMain/rust/bridge/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl FromProtobuf<Action> for runtime::Action {
Some(action_ctx::Args::InstallTraktAddon(_args)) => {
Action::Ctx(ActionCtx::InstallTraktAddon)
}
Some(action_ctx::Args::LogoutTrakt(_args)) => Action::Ctx(ActionCtx::LogoutTrakt),
Some(action_ctx::Args::UpgradeAddon(descriptor)) => {
Action::Ctx(ActionCtx::UpgradeAddon(descriptor.from_protobuf()))
}
Expand All @@ -49,6 +50,12 @@ impl FromProtobuf<Action> for runtime::Action {
Some(action_ctx::Args::RewindLibraryItem(id)) => {
Action::Ctx(ActionCtx::RewindLibraryItem(id.to_owned()))
}
Some(action_ctx::Args::ToggleLibraryItemNotifications(args)) => Action::Ctx(
ActionCtx::ToggleLibraryItemNotifications(args.id.to_owned(), args.toggle),
),
Some(action_ctx::Args::DismissNotificationItem(id)) => {
Action::Ctx(ActionCtx::DismissNotificationItem(id.to_owned()))
}
Some(action_ctx::Args::PushUserToApi(_args)) => {
Action::Ctx(ActionCtx::PushUserToAPI)
}
Expand All @@ -64,6 +71,9 @@ impl FromProtobuf<Action> for runtime::Action {
Some(action_ctx::Args::SyncLibraryWithApi(_args)) => {
Action::Ctx(ActionCtx::SyncLibraryWithAPI)
}
Some(action_ctx::Args::PullNotifications(_args)) => {
Action::Ctx(ActionCtx::PullNotifications)
}
None => unimplemented!("ActionCtx missing"),
},
Some(runtime::action::Type::Link(action_link)) => match &action_link.args {
Expand Down Expand Up @@ -211,6 +221,10 @@ impl FromProtobuf<Action> for runtime::Action {
Action::Load(ActionLoad::Player(Box::new(selected.from_protobuf())))
}
Some(action_load::Args::Link(_args)) => Action::Load(ActionLoad::Link),
Some(action_load::Args::DataExport(_args)) => Action::Load(ActionLoad::DataExport),
Some(action_load::Args::LocalSearch(_args)) => {
Action::Load(ActionLoad::LocalSearch)
}
None => unimplemented!("ActionLoad missing"),
},
Some(runtime::action::Type::Unload(_args)) => Action::Unload,
Expand Down
5 changes: 5 additions & 0 deletions src/commonMain/rust/bridge/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ impl ToProtobuf<runtime::Event, ()> for Event {
Event::StreamsPushedToStorage { uid } => runtime::event::Type::StreamsPushedToStorage(
runtime::event::StreamsPushedToStorage { uid: uid.clone() },
),
Event::SearchHistoryPushedToStorage { uid } => {
runtime::event::Type::SearchHistoryPushedToStorage(
runtime::event::SearchHistoryPushedToStorage { uid: uid.clone() },
)
}
Event::NotificationsPushedToStorage { ids } => {
runtime::event::Type::NotificationsPushedToStorage(
runtime::event::NotificationsPushedToStorage { ids: ids.clone() },
Expand Down
1 change: 1 addition & 0 deletions src/commonMain/rust/bridge/library_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl ToProtobuf<types::LibraryItem, Ctx> for LibraryItem {
time_offset: self.state.time_offset,
duration: self.state.duration,
video_id: self.state.video_id.clone(),
no_notif: self.state.no_notif,
},
behavior_hints: self.behavior_hints.to_protobuf(&()),
deep_links: types::MetaItemDeepLinks {
Expand Down
34 changes: 34 additions & 0 deletions src/commonMain/rust/bridge/loadable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,40 @@ impl
}
}

impl
ToProtobuf<
models::loadable_stream::Content,
(&Ctx, &String, &ResourceRequest, Option<&ResourceRequest>),
> for Loadable<Option<Stream>, ResourceError>
{
fn to_protobuf(
&self,
(ctx, addon_name, stream_request, meta_request): &(
&Ctx,
&String,
&ResourceRequest,
Option<&ResourceRequest>,
),
) -> models::loadable_stream::Content {
match &self {
Loadable::Ready(ready) => {
models::loadable_stream::Content::Ready(models::OptionStream {
stream: ready.to_protobuf(&(
Some(*ctx),
Some(*addon_name),
Some(*stream_request),
*meta_request,
)),
})
}
Loadable::Err(error) => models::loadable_stream::Content::Error(models::Error {
message: error.to_string(),
}),
Loadable::Loading => models::loadable_stream::Content::Loading(models::Loading {}),
}
}
}

impl ToProtobuf<models::loadable_subtitles::Content, Option<&String>>
for Loadable<Vec<Subtitles>, ResourceError>
{
Expand Down
2 changes: 2 additions & 0 deletions src/commonMain/rust/bridge/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl FromProtobuf<Settings> for types::profile::Settings {
seek_short_time_duration: u32::try_from(cmp::max(self.seek_time_duration, 0))
.unwrap_or(u32::MAX),
pause_on_minimize: self.pause_on_minimize,
surround_sound: self.surround_sound,
streaming_server_warning_dismissed: None,
}
}
Expand Down Expand Up @@ -175,6 +176,7 @@ impl ToProtobuf<types::profile::Settings, ()> for Settings {
player_type: self.player_type.clone(),
frame_rate_matching_strategy: self.frame_rate_matching_strategy.to_protobuf(&()) as i32,
next_video_notification_duration: self.next_video_notification_duration as i64,
surround_sound: self.surround_sound,
}
}
}
Expand Down
55 changes: 31 additions & 24 deletions src/commonMain/rust/bridge/resource_loadable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use stremio_core::types::addon::{DescriptorPreview, ResourceRequest};
use stremio_core::types::library::LibraryItem;
use stremio_core::types::resource::{MetaItem, MetaItemPreview, Stream, Subtitles};
use stremio_watched_bitfield::WatchedBitField;
use url::Url;

use crate::bridge::ToProtobuf;
use crate::protobuf::stremio::core::models;
Expand Down Expand Up @@ -54,14 +55,7 @@ impl ToProtobuf<models::LoadableMetaItem, (&Ctx, Option<&LibraryItem>, Option<&W
&self,
(ctx, library_item, watched): &(&Ctx, Option<&LibraryItem>, Option<&WatchedBitField>),
) -> models::LoadableMetaItem {
let addon_name = ctx
.profile
.addons
.iter()
.find(|addon| addon.transport_url == self.request.base)
.map(|addon| &addon.manifest.name)
.cloned()
.unwrap_or_default();
let addon_name = get_addon_name(ctx, &self.request.base);
models::LoadableMetaItem {
title: addon_name.to_string(),
request: self.request.to_protobuf(&()),
Expand All @@ -82,14 +76,7 @@ impl ToProtobuf<models::LoadableStreams, (&Ctx, Option<&ResourceRequest>)>
&self,
(ctx, meta_request): &(&Ctx, Option<&ResourceRequest>),
) -> models::LoadableStreams {
let addon_name = ctx
.profile
.addons
.iter()
.find(|addon| addon.transport_url == self.request.base)
.map(|addon| &addon.manifest.name)
.cloned()
.unwrap_or_default();
let addon_name = get_addon_name(ctx, &self.request.base);
models::LoadableStreams {
title: addon_name.to_owned(),
request: self.request.to_protobuf(&()),
Expand All @@ -100,16 +87,26 @@ impl ToProtobuf<models::LoadableStreams, (&Ctx, Option<&ResourceRequest>)>
}
}

impl ToProtobuf<models::LoadableStream, (&Ctx, Option<&ResourceRequest>)>
for ResourceLoadable<Option<Stream>>
{
fn to_protobuf(
&self,
(ctx, meta_request): &(&Ctx, Option<&ResourceRequest>),
) -> models::LoadableStream {
let addon_name = get_addon_name(ctx, &self.request.base);
models::LoadableStream {
request: self.request.to_protobuf(&()),
content: self
.content
.to_protobuf(&(ctx, &addon_name, &self.request, *meta_request)),
}
}
}

impl ToProtobuf<models::LoadableSubtitles, Ctx> for ResourceLoadable<Vec<Subtitles>> {
fn to_protobuf(&self, ctx: &Ctx) -> models::LoadableSubtitles {
let addon_name = ctx
.profile
.addons
.iter()
.find(|addon| addon.transport_url == self.request.base)
.map(|addon| &addon.manifest.name)
.cloned()
.unwrap_or_default();
let addon_name = get_addon_name(ctx, &self.request.base);
models::LoadableSubtitles {
title: addon_name.to_owned(),
request: self.request.to_protobuf(&()),
Expand All @@ -135,3 +132,13 @@ impl ToProtobuf<models::LoadableDescriptor, Ctx> for DescriptorLoadable {
}
}
}

fn get_addon_name(ctx: &Ctx, addon_url: &Url) -> String {
ctx.profile
.addons
.iter()
.find(|addon| &addon.transport_url == addon_url)
.map(|addon| &addon.manifest.name)
.cloned()
.unwrap_or_default()
}
28 changes: 4 additions & 24 deletions src/commonMain/rust/model/fields/meta_details.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use boolinator::Boolinator;
use stremio_core::deep_links::MetaItemDeepLinks;
use stremio_core::models::common::Loadable;
use stremio_core::models::ctx::Ctx;
use stremio_core::models::meta_details::{MetaDetails, Selected};
use stremio_core::runtime::Env;
Expand Down Expand Up @@ -159,6 +158,9 @@ impl
}
}),
in_library: library_item.map(|item| !item.removed).unwrap_or_default(),
receive_notifications: library_item
.map(|item| !item.state.no_notif)
.unwrap_or_default(),
}
}
}
Expand Down Expand Up @@ -218,23 +220,6 @@ impl ToProtobuf<models::MetaDetails, Ctx> for MetaDetails {
})
.unwrap_or_else(|| meta_item.preview.name.to_owned())
});
let suggested_stream_request =
self.suggested_stream.as_ref().and_then(|suggested_stream| {
streams
.iter()
.find(|resource| match &resource.content {
Some(Loadable::Ready(streams)) => streams.contains(suggested_stream),
_ => false,
})
.map(|resource| &resource.request)
});
let suggested_stream_addon_name = suggested_stream_request.and_then(|stream_request| {
ctx.profile
.addons
.iter()
.find(|addon| addon.transport_url == stream_request.base)
.map(|addon| &addon.manifest.name)
});
models::MetaDetails {
selected: self.selected.to_protobuf(&()),
title,
Expand All @@ -244,12 +229,7 @@ impl ToProtobuf<models::MetaDetails, Ctx> for MetaDetails {
self.watched.as_ref(),
)),
streams: streams.to_protobuf(&(ctx, meta_request)),
suggested_stream: self.suggested_stream.to_protobuf(&(
Some(ctx),
suggested_stream_addon_name,
suggested_stream_request,
meta_request,
)),
suggested_stream: self.suggested_stream.to_protobuf(&(ctx, meta_request)),
}
}
}
Loading

0 comments on commit 9e877fd

Please sign in to comment.