diff --git a/Cargo.toml b/Cargo.toml index 68773c47f..9af906362 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ members = [ # TODO: env-future-send should be enabled by default # but our `TestEnv` for `unit_tests` uses a MutexGuard which is not Send. # default = ["env-future-send"] -default = ["typed-states", "dep:actix-web"] +default = ["typed-states", "actix-web"] # Adds `Send` marker trait to the `Env` trait methods and `EnvFuture`. # It's required for environments that do not support `Send`. @@ -38,6 +38,7 @@ derive = [] analytics = [] typed-states = ["dep:typed-builder"] +actix-web = ["dep:actix-web"] [dependencies] stremio-derive = { path = "stremio-derive" } diff --git a/src/deep_links/mod.rs b/src/deep_links/mod.rs index 6513ea5d1..dab5dcdbc 100644 --- a/src/deep_links/mod.rs +++ b/src/deep_links/mod.rs @@ -1,6 +1,6 @@ use percent_encoding::utf8_percent_encode; use regex::Regex; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use url::Url; use crate::{ @@ -23,7 +23,17 @@ pub use error_link::ErrorLink; mod error_link; -#[derive(Default, Serialize, Debug, PartialEq, Eq)] +#[cfg(feature = "actix-web")] +mod actix_test { + use actix_web::get; + + #[get("/{root}/{type}")] + pub async fn library_deeplink() -> impl actix_web::Responder { + format!("Hello!") + } +} + +#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct OpenPlayerLink { pub ios: Option, @@ -40,7 +50,7 @@ pub struct OpenPlayerLink { pub visionos: Option, } -#[derive(Default, Serialize, Debug, PartialEq, Eq)] +#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct ExternalPlayerLink { pub download: Option, @@ -332,7 +342,7 @@ impl From<(&MetaItem, &ResourceRequest)> for MetaItemDeepLinks { } } -#[derive(Serialize)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct VideoDeepLinks { pub meta_details_videos: String, @@ -438,7 +448,8 @@ impl } } -#[derive(Serialize)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] +// #[serde(rename_all = "camelCase", from = (&Stream, &Option, &Settings))] #[serde(rename_all = "camelCase")] pub struct StreamDeepLinks { pub player: String, diff --git a/src/models/player.rs b/src/models/player.rs index e5576e923..9f7af204d 100644 --- a/src/models/player.rs +++ b/src/models/player.rs @@ -10,6 +10,7 @@ use crate::constants::{ STREAM_RESOURCE_NAME, SUBTITLES_RESOURCE_NAME, VIDEO_FILENAME_EXTRA_PROP, VIDEO_HASH_EXTRA_PROP, VIDEO_SIZE_EXTRA_PROP, WATCHED_THRESHOLD_COEF, }; +use crate::deep_links::{StreamDeepLinks, VideoDeepLinks}; use crate::models::common::{ eq_update, resource_update, resource_update_with_vector_content, resources_update_with_vector_content, Loadable, ResourceAction, ResourceLoadable, @@ -75,6 +76,12 @@ pub struct VideoParams { pub filename: Option, } +#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] +pub struct DeepLinks { + stream: StreamDeepLinks, + video: VideoDeepLinks, +} + #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct Selected { @@ -83,6 +90,7 @@ pub struct Selected { /// A request to fetch the selected [`MetaItem`]. pub meta_request: Option, pub subtitles_path: Option, + pub deeplinks: DeepLinks } #[derive(Clone, Derivative, Serialize, Debug)]