Skip to content

Commit

Permalink
Merge pull request #570 from Stremio/filename-video-param
Browse files Browse the repository at this point in the history
add `filename` video param
  • Loading branch information
unclekingpin authored Dec 1, 2023
2 parents 316c74e + eee94ea commit df9b510
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
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 =
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()),
..subtitles_path.to_owned()
}),
addons,
Expand Down

0 comments on commit df9b510

Please sign in to comment.