Skip to content
Open
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
24 changes: 20 additions & 4 deletions src/deep_links/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct OpenPlayerLink {
#[serde(default, skip_serializing_if = "Option::is_none")]
/// VisionOS
pub visionos: Option<String>,
pub tvos: Option<String>,
}

#[derive(Default, Serialize, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -132,10 +133,17 @@ impl From<(&Stream, Option<&Url>, &Settings)> for ExternalPlayerLink {
// Either a query that's url-safe or encoded.
// https://support.firecore.com/hc/en-us/articles/215090997-API-for-Third-Party-Apps-Services#h_01HDS4GZEG00ME3VJJ77SEFF5V
"infuse" => Some(OpenPlayerLink {
ios: Some(format!("infuse://x-callback-url/play?url={url_encoded}")),
..Default::default()
ios: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url_encoded}")),
macos: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url_encoded}")),
visionos: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url_encoded}")),
tvos: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url_encoded}")),
..Default::default()
}),
"vidhub" => Some(OpenPlayerLink {
ios: Some(format!("open-vidhub://x-callback-url/open?on-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&on-failed=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url_encoded}")),
macos: Some(format!("open-vidhub://x-callback-url/open?on-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&on-failed=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url_encoded}")),
..Default::default()
}),

"iina" => Some(OpenPlayerLink {
macos: Some(format!("iina://weblink?url={url_encoded}")),
..Default::default()
Expand Down Expand Up @@ -256,9 +264,17 @@ impl From<(&Stream<ConvertedStreamSource>, Option<&Url>, &Settings)> for Externa
..Default::default()
}),
"infuse" => Some(OpenPlayerLink {
ios: Some(format!("infuse://x-callback-url/play?url={url}")),
ios: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url}")),
macos: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url}")),
visionos: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url}")),
tvos: Some(format!("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url}")),
..Default::default()
}),
"vidhub" => Some(OpenPlayerLink {
ios: Some(format!("open-vidhub://x-callback-url/open?on-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&on-failed=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url}")),
macos: Some(format!("open-vidhub://x-callback-url/open?on-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&on-failed=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url={url}")),
..Default::default()
}),
"iina" => Some(OpenPlayerLink {
macos: Some(format!("iina://weblink?url={url}")),
..Default::default()
Expand Down
36 changes: 35 additions & 1 deletion src/unit_tests/deep_links/external_player_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,40 @@ fn external_player_link_with_infuse() {

assert_eq!(
open_player.ios,
Some("infuse://x-callback-url/play?url=http%3A%2F%2Fexample.com%2Fstream".to_string())
Some("infuse://x-callback-url/play?x-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&x-error=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url=http%3A%2F%2Fexample.com%2Fstream".to_string())
);
}

#[test]
fn external_player_link_and_callback_with_vidhub() {
let stream = Stream {
source: StreamSource::Url {
url: Url::from_str("http://example.com/stream").unwrap(),
},
name: None,
description: None,
thumbnail: None,
subtitles: vec![],
behavior_hints: Default::default(),
};

let streaming_server_url = Some(Url::parse(STREAMING_SERVER_URL).unwrap());

let settings = Settings {
player_type: Some("vidhub".to_string()),
streaming_server_url: Url::parse(STREAMING_SERVER_URL).unwrap(),
..Default::default()
};

let epl = ExternalPlayerLink::from((&stream, streaming_server_url.as_ref(), &settings));

let open_player = epl.open_player.as_ref().unwrap();

assert_eq!(
open_player.ios,
Some(
"open-vidhub://x-callback-url/open?on-success=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D1&on-failed=stremio%3A%2F%2F%2Fplayer%3FexternalPlayerSuccess%3D0&url=http%3A%2F%2Fexample.com%2Fstream"
.to_string()
)
);
}