Skip to content

Commit

Permalink
add filename video param
Browse files Browse the repository at this point in the history
  • Loading branch information
unclekingpin committed Dec 1, 2023
1 parent f2517fb commit 71b8012
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 @@ -213,6 +215,14 @@ fn build_legacy_req(transport_url: &Url, path: &ResourcePath) -> Result<Request<
let video_size = path
.get_extra_first_value(VIDEO_SIZE_EXTRA_PROP.name.as_str())
.and_then(|video_size| video_size.parse().ok());
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()),
);
}
if let Some(video_size) = video_size {
query.insert(
VIDEO_SIZE_EXTRA_PROP.name.as_str(),
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 71b8012

Please sign in to comment.