Skip to content

Commit

Permalink
fix: build after core update with new features:
Browse files Browse the repository at this point in the history
- add new events and handle them
- add new StreamingServer Urls bucket
- add Subtitle id field

Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Dec 6, 2024
1 parent ac8c75b commit b5afc7a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
6 changes: 3 additions & 3 deletions stremio-core-kotlin/src/commonMain/rust/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ use stremio_core::{
},
runtime::Effects,
types::{
api::LinkAuthKey, events::DismissedEventsBucket, library::LibraryBucket,
notifications::NotificationsBucket, profile::Profile, resource::MetaItemPreview,
search_history::SearchHistoryBucket, streams::StreamsBucket,
api::LinkAuthKey, events::DismissedEventsBucket, library::LibraryBucket, notifications::NotificationsBucket, profile::Profile, resource::MetaItemPreview, search_history::SearchHistoryBucket, server_urls::ServerUrlsBucket, streams::StreamsBucket
},
Model,
};
Expand Down Expand Up @@ -56,6 +54,7 @@ impl AndroidModel {
profile: Profile,
library: LibraryBucket,
streams: StreamsBucket,
server_urls: ServerUrlsBucket,
notifications: NotificationsBucket,
search_history: SearchHistoryBucket,
dismissed_events: DismissedEventsBucket,
Expand All @@ -79,6 +78,7 @@ impl AndroidModel {
profile,
library,
streams,
server_urls,
notifications,
search_history,
dismissed_events,
Expand Down
15 changes: 10 additions & 5 deletions stremio-core-kotlin/src/commonMain/rust/stremio_core_kotlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ use stremio_core::{
constants::{
DISMISSED_EVENTS_STORAGE_KEY, LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY,
NOTIFICATIONS_STORAGE_KEY, PROFILE_STORAGE_KEY, SEARCH_HISTORY_STORAGE_KEY,
STREAMS_STORAGE_KEY,
STREAMING_SERVER_URLS_STORAGE_KEY, STREAMS_STORAGE_KEY,
},
models::common::Loadable,
runtime::{Env, EnvError, Runtime, RuntimeEvent},
types::{
events::DismissedEventsBucket, library::LibraryBucket, notifications::NotificationsBucket,
profile::Profile, resource::Stream, search_history::SearchHistoryBucket,
streams::StreamsBucket,
server_urls::ServerUrlsBucket, streams::StreamsBucket,
},
};
use stremio_core_protobuf::{FromProtobuf, ToProtobuf};
Expand Down Expand Up @@ -67,20 +67,22 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative(
let init_result = AndroidEnv::exec_sync(AndroidEnv::init(&env, storage));
match init_result {
Ok(_) => {
let storage_result = AndroidEnv::exec_sync(future::try_join3(
let storage_result = AndroidEnv::exec_sync(future::try_join4(
future::try_join5(
AndroidEnv::get_storage::<Profile>(PROFILE_STORAGE_KEY),
AndroidEnv::get_storage::<LibraryBucket>(LIBRARY_RECENT_STORAGE_KEY),
AndroidEnv::get_storage::<LibraryBucket>(LIBRARY_STORAGE_KEY),
AndroidEnv::get_storage::<StreamsBucket>(STREAMS_STORAGE_KEY),
AndroidEnv::get_storage::<NotificationsBucket>(NOTIFICATIONS_STORAGE_KEY),
AndroidEnv::get_storage::<ServerUrlsBucket>(STREAMING_SERVER_URLS_STORAGE_KEY),
),
AndroidEnv::get_storage::<NotificationsBucket>(NOTIFICATIONS_STORAGE_KEY),
AndroidEnv::get_storage::<SearchHistoryBucket>(SEARCH_HISTORY_STORAGE_KEY),
AndroidEnv::get_storage::<DismissedEventsBucket>(DISMISSED_EVENTS_STORAGE_KEY),
));
match storage_result {
Ok((
(profile, recent_bucket, other_bucket, streams, notifications),
(profile, recent_bucket, other_bucket, streams, server_urls_bucket),
notifications,
search_history,
dismissed_events,
)) => {
Expand All @@ -93,6 +95,8 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative(
library.merge_bucket(other_bucket);
};
let streams = streams.unwrap_or(StreamsBucket::new(profile.uid()));
let server_urls_bucket =
server_urls_bucket.unwrap_or(ServerUrlsBucket::new::<AndroidEnv>(profile.uid()));
let notifications = notifications.unwrap_or(NotificationsBucket::new::<
AndroidEnv,
>(
Expand All @@ -106,6 +110,7 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative(
profile,
library,
streams,
server_urls_bucket,
notifications,
search_history,
dismissed_events,
Expand Down
8 changes: 8 additions & 0 deletions stremio-core-protobuf/proto/stremio/core/runtime/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ message Event {
MagnetParsed magnet_parsed = 37;
TorrentParsed torrent_parsed = 38;
PlayingOnDevice playing_on_device = 39;
StreamingServerUrlsBucketChanged streaming_server_urls_bucket_changed = 40;
StreamingServerUrlsPushedToStorage streaming_server_urls_pushed_to_storage = 41;
Error error = 100;
}

Expand Down Expand Up @@ -173,6 +175,12 @@ message Event {
message PlayingOnDevice {
required string device = 1;
}
message StreamingServerUrlsBucketChanged {
optional string uid = 1;
}
message StreamingServerUrlsPushedToStorage {
optional string uid = 1;
}
message Error {
required string error = 1;
required Event source = 2;
Expand Down
7 changes: 4 additions & 3 deletions stremio-core-protobuf/proto/stremio/core/types/subtitle.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ package stremio.core.types;
option java_package = "com.stremio.core.types.subtitle";

message Subtitle {
required string lang = 1;
required string url = 2;
optional string name = 3;
required string id = 1;
required string lang = 2;
required string url = 3;
optional string name = 4;
}
14 changes: 14 additions & 0 deletions stremio-core-protobuf/src/bridge/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ impl ToProtobuf<runtime::Event, ()> for Event {
device: device.to_owned(),
})
}
Event::StreamingServerUrlsBucketChanged { uid } => {
runtime::event::Type::StreamingServerUrlsBucketChanged(
runtime::event::StreamingServerUrlsBucketChanged {
uid: uid.to_owned(),
},
)
}
Event::StreamingServerUrlsPushedToStorage { uid } => {
runtime::event::Type::StreamingServerUrlsPushedToStorage(
runtime::event::StreamingServerUrlsPushedToStorage {
uid: uid.to_owned(),
},
)
}
Event::Error { error, source } => {
let error = match error {
CtxError::API(error) => error.message.to_owned(),
Expand Down
2 changes: 2 additions & 0 deletions stremio-core-protobuf/src/bridge/subtitle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::protobuf::stremio::core::types;
impl FromProtobuf<Subtitles> for types::Subtitle {
fn from_protobuf(&self) -> Subtitles {
Subtitles {
id: self.id.clone(),
lang: self.lang.to_string(),
url: self.url.from_protobuf(),
}
Expand All @@ -18,6 +19,7 @@ impl ToProtobuf<types::Subtitle, Option<&String>> for Subtitles {
addon_name: &Option<&String>,
) -> types::Subtitle {
types::Subtitle {
id: self.id.clone(),
lang: self.lang.to_string(),
url: self.url.to_string(),
name: addon_name.cloned(),
Expand Down

0 comments on commit b5afc7a

Please sign in to comment.