Skip to content

Commit

Permalink
WIP: Player deeplinks & actix route definition
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Nov 25, 2024
1 parent d61cc4d commit 1612b79
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -38,6 +38,7 @@ derive = []
analytics = []

typed-states = ["dep:typed-builder"]
actix-web = ["dep:actix-web"]

[dependencies]
stremio-derive = { path = "stremio-derive" }
Expand Down
21 changes: 16 additions & 5 deletions src/deep_links/mod.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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<String>,
Expand All @@ -40,7 +50,7 @@ pub struct OpenPlayerLink {
pub visionos: Option<String>,
}

#[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<String>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -438,7 +448,8 @@ impl
}
}

#[derive(Serialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
// #[serde(rename_all = "camelCase", from = (&Stream, &Option<Url>, &Settings))]
#[serde(rename_all = "camelCase")]
pub struct StreamDeepLinks {
pub player: String,
Expand Down
8 changes: 8 additions & 0 deletions src/models/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -75,6 +76,12 @@ pub struct VideoParams {
pub filename: Option<String>,
}

#[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 {
Expand All @@ -83,6 +90,7 @@ pub struct Selected {
/// A request to fetch the selected [`MetaItem`].
pub meta_request: Option<ResourceRequest>,
pub subtitles_path: Option<ResourcePath>,
pub deeplinks: DeepLinks
}

#[derive(Clone, Derivative, Serialize, Debug)]
Expand Down

0 comments on commit 1612b79

Please sign in to comment.