Skip to content

Commit

Permalink
feat: Zip, Rar & Nzb implementation and fixes
Browse files Browse the repository at this point in the history
feat: add dep on uuid and introduce a feature for wasm in core
feat: enable core feature for wasm (uuid)

Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Jan 27, 2025
1 parent 1ad5a7b commit 64fb707
Show file tree
Hide file tree
Showing 12 changed files with 416 additions and 147 deletions.
84 changes: 84 additions & 0 deletions Cargo.lock

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

17 changes: 11 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ opt-level = 's'

[workspace]
resolver = "2"
members = [
"stremio-core-web",
"stremio-derive",
"stremio-watched-bitfield",
]
members = ["stremio-core-web", "stremio-derive", "stremio-watched-bitfield"]

[features]
# TODO: env-future-send should be enabled by default
Expand All @@ -37,13 +33,16 @@ derive = []
# Enable core analytics
analytics = []

# enables WASM specific features for core
wasm = ["uuid/js"]

[dependencies]
stremio-derive = { path = "stremio-derive" }
stremio-watched-bitfield = { path = "stremio-watched-bitfield" }
stremio-official-addons = "=2.0.13"

# (De)Serialization
serde = { version = "1", features = ["derive"]}
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.*"
serde_path_to_error = "0.1"
serde_url_params = "0.2"
Expand Down Expand Up @@ -96,6 +95,12 @@ num = { version = "0.4.0", default-features = false }
# Tracing
tracing = "0.1"

uuid = { version = "1.12.1", features = [
"v4", # Lets you generate random UUIDs
"fast-rng", # Use a faster (but still sufficiently random) RNG
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
]}

[dev-dependencies]
tokio = { version = "1.12", features = ["rt", "macros"] }
tokio-current-thread = "=0.2.0-alpha.1"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::all)]
//! # Stremio core
#![allow(clippy::module_inception)]
// Do not allow broken intra doc links
Expand Down
51 changes: 21 additions & 30 deletions src/models/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ use crate::types::profile::{Profile, Settings as ProfileSettings};
use crate::types::resource::{
MetaItem, SeriesInfo, Stream, StreamSource, StreamUrls, Subtitles, Video,
};
use crate::types::streams::{ConvertedStreamSource, StreamItemState, StreamsBucket, StreamsItemKey};
use crate::types::streams::{
ConvertedStreamSource, StreamItemState, StreamsBucket, StreamsItemKey,
};

use stremio_watched_bitfield::WatchedBitField;

Expand Down Expand Up @@ -639,21 +641,8 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
.map(|library_item| library_item.state.time_offset),
);

let item_state_update_effects = item_state_update(&mut self.library_item, &self.next_video);
// let item_state_update_effects = if self
// .selected
// .as_ref()
// .and_then(|selected| selected.meta_request.as_ref())
// .map(|meta_request| &meta_request.path.id)
// != self.selected
// .meta_request
// .as_ref()
// .map(|meta_request| &meta_request.path.id)
// {
// item_state_update(&mut self.library_item, &self.next_video)
// } else {
// Effects::none().unchanged()
// };
let item_state_update_effects =
item_state_update(&mut self.library_item, &self.next_video);

// Set time_offset to 0 as we switch to next video
let library_item_effects = self
Expand All @@ -672,7 +661,7 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {

// Load will actually take care of loading the next video
seek_history_effects
.join(item_state_update_effects)
.join(item_state_update_effects)
.join(
Effects::msg(Msg::Event(Event::PlayerNextVideo {
context: self.analytics_context.as_ref().cloned().unwrap_or_default(),
Expand Down Expand Up @@ -894,13 +883,10 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
converted_stream.to_owned(),
streaming_server_url.as_ref(),
);

Loadable::Ready((stream_urls, converted_stream.to_owned()))
},
Err(err) => {
tracing::info!("failed here");
Loadable::Err(err.to_owned())
},
}
Err(err) => Loadable::Err(err.to_owned()),
};

eq_update(&mut self.stream, next_stream)
Expand Down Expand Up @@ -1333,8 +1319,11 @@ fn calculate_outro(library_item: &LibraryItem, closest_duration: u64, closest_ou
let duration_diff_in_secs =
(library_item.state.duration.abs_diff(closest_duration)).div(1000 * 10) / 10;
tracing::debug!(
closest_duration,
closest_outro,
"Player: Outro match by duration with difference of {duration_diff_in_secs} seconds"
);

library_item
.state
.duration
Expand Down Expand Up @@ -1402,18 +1391,20 @@ fn intro_outro_update<E: Env + 'static>(

closest_duration.and_then(|(closest_duration, skip_gaps)| {
let duration_diff_in_secs = (library_item.state.duration.abs_diff(*closest_duration)).div(1000 * 10) / 10;
tracing::trace!("Player: Intro match by duration with difference of {duration_diff_in_secs} seconds");

let duration_ration = Ratio::new(library_item.state.duration, *closest_duration);

// even though we checked for len() > 0 make sure we don't panic if somebody decides to remove that check!
skip_gaps.seek_history.first().map(|seek_event| {
IntroData {
let matched_intro = skip_gaps.seek_history.first().map(|seek_event| {
let intro_data = IntroData {
from: (duration_ration * seek_event.from).to_integer(),
to: (duration_ration * seek_event.to).to_integer(),
duration: if duration_diff_in_secs > 0 { Some(seek_event.to.abs_diff(seek_event.from)) } else { None }
}
})
};
tracing::debug!(?seek_event, ?intro_data, "Player: Intro match for event by duration with difference of {duration_diff_in_secs} seconds",);
intro_data
})?;


Some(matched_intro)
})
};

Expand Down
Loading

0 comments on commit 64fb707

Please sign in to comment.