Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filename video param #570

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/addon_transport/http_transport/legacy/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::addon_transport::AddonTransport;
use crate::constants::{BASE64, VIDEO_HASH_EXTRA_PROP, VIDEO_SIZE_EXTRA_PROP};
use crate::constants::{
BASE64, VIDEO_FILENAME_EXTRA_PROP, VIDEO_HASH_EXTRA_PROP, VIDEO_SIZE_EXTRA_PROP,
};
use crate::runtime::{ConditionalSend, Env, EnvError, EnvFutureExt, TryEnvFuture};
use crate::types::addon::{Manifest, ResourcePath, ResourceResponse};
use crate::types::resource::{MetaItem, MetaItemPreview, Stream, Subtitles};
Expand Down Expand Up @@ -219,6 +221,14 @@ fn build_legacy_req(transport_url: &Url, path: &ResourcePath) -> Result<Request<
serde_json::Value::Number(video_size),
);
}
let video_filename =
TheBeastLT marked this conversation as resolved.
Show resolved Hide resolved
path.get_extra_first_value(VIDEO_FILENAME_EXTRA_PROP.name.as_str());
if let Some(video_filename) = video_filename {
query.insert(
VIDEO_FILENAME_EXTRA_PROP.name.as_str(),
serde_json::Value::String(video_filename.to_owned()),
);
}
build_jsonrpc("subtitles.find", json!({ "query": query }))
}
_ => return Err(LegacyErr::UnsupportedRequest.into()),
Expand Down
6 changes: 6 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ lazy_static! {
options: vec![],
options_limit: OptionsLimit::default(),
};
pub static ref VIDEO_FILENAME_EXTRA_PROP: ExtraProp = ExtraProp {
name: "filename".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit::default(),
};
pub static ref LAST_VIDEOS_IDS_EXTRA_PROP: ExtraProp = ExtraProp {
name: "lastVideosIds".to_owned(),
is_required: false,
Expand Down
7 changes: 5 additions & 2 deletions src/models/player.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::marker::PhantomData;

use crate::constants::{
CREDITS_THRESHOLD_COEF, VIDEO_HASH_EXTRA_PROP, VIDEO_SIZE_EXTRA_PROP, WATCHED_THRESHOLD_COEF,
CREDITS_THRESHOLD_COEF, VIDEO_FILENAME_EXTRA_PROP, VIDEO_HASH_EXTRA_PROP,
VIDEO_SIZE_EXTRA_PROP, WATCHED_THRESHOLD_COEF,
};
use crate::models::common::{
eq_update, resource_update, resources_update_with_vector_content, Loadable, ResourceAction,
Expand Down Expand Up @@ -59,6 +60,7 @@ pub struct AnalyticsContext {
pub struct VideoParams {
pub hash: Option<String>,
pub size: Option<u64>,
pub filename: Option<String>,
}

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -860,7 +862,8 @@ fn subtitles_update<E: Env + 'static>(
.extend_one(
&VIDEO_SIZE_EXTRA_PROP,
video_params.size.as_ref().map(|size| size.to_string()),
),
)
.extend_one(&VIDEO_FILENAME_EXTRA_PROP, video_params.filename.to_owned()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is going to be part of Stream.behaviourHints object, maybe we should take from there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that logic is in stremio-video

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tho that means that every client will have to duplicate this logic, extracting values from Stream.behaviourHints and passing them via VideoParams instead of core taking care of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, every non js app :(
we can think of way to move that logic to rust

..subtitles_path.to_owned()
}),
addons,
Expand Down