Skip to content

Commit

Permalink
Merge pull request #557 from Stremio/fix/external-player-link-streami…
Browse files Browse the repository at this point in the history
…ng-server-url

Fix external player link streaming server url
  • Loading branch information
elpiel authored Nov 20, 2023
2 parents 75cfb62 + 2e85612 commit 1f78803
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/deep_links/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ impl From<(&Stream, Option<&Url>, &Settings)> for ExternalPlayerLink {
///
/// [`StreamingServer::base_url`]: crate::models::streaming_server::StreamingServer::base_url
fn from((stream, streaming_server_url, settings): (&Stream, Option<&Url>, &Settings)) -> Self {
// Use streaming_server_url from settings if streaming_server is reachable
let streaming_server_url = streaming_server_url.map(|_| &settings.streaming_server_url);
let http_regex = Regex::new(r"https?://").unwrap();
let download = stream.download_url();
let streaming = stream.streaming_url(streaming_server_url);
Expand Down
9 changes: 3 additions & 6 deletions src/types/resource/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,9 @@ impl Stream {
}
pub fn streaming_url(&self, streaming_server_url: Option<&Url>) -> Option<String> {
match (&self.source, streaming_server_url) {
(StreamSource::Url { url }, _) if url.scheme() != "magnet" => {
match (streaming_server_url, &self.behavior_hints.proxy_headers) {
(
Some(streaming_server_url),
Some(StreamProxyHeaders { request, response }),
) => {
(StreamSource::Url { url }, Some(streaming_server_url)) if url.scheme() != "magnet" => {
match &self.behavior_hints.proxy_headers {
Some(StreamProxyHeaders { request, response }) => {
let mut streaming_url = streaming_server_url.to_owned();
let mut proxy_query = form_urlencoded::Serializer::new(String::new());
let origin = format!("{}://{}", url.scheme(), url.authority());
Expand Down
2 changes: 1 addition & 1 deletion src/unit_tests/deep_links/external_player_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use url::Url;
const MAGNET_STR_URL: &str = "magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce";
const HTTP_STR_URL: &str = "http://domain.root/path";
const BASE64_HTTP_URL: &str = "data:application/octet-stream;charset=utf-8;base64,I0VYVE0zVQojRVhUSU5GOjAKaHR0cDovL2RvbWFpbi5yb290L3BhdGg=";
const STREAMING_SERVER_URL: &str = "http://127.0.0.1:11471";
const STREAMING_SERVER_URL: &str = "http://127.0.0.1:11470";

#[test]
fn external_player_link_magnet() {
Expand Down
2 changes: 1 addition & 1 deletion src/unit_tests/deep_links/stream_deep_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MAGNET_STR_URL: &str = "magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d870
const HTTP_STR_URL: &str = "http://domain.root/path";
const HTTP_WITH_QUERY_STR_URL: &str = "http://domain.root/path?param=some&foo=bar";
const BASE64_HTTP_URL: &str = "data:application/octet-stream;charset=utf-8;base64,I0VYVE0zVQojRVhUSU5GOjAKaHR0cDovL2RvbWFpbi5yb290L3BhdGg=";
const STREAMING_SERVER_URL: &str = "http://127.0.0.1:11471";
const STREAMING_SERVER_URL: &str = "http://127.0.0.1:11470";
const YT_ID: &str = "aqz-KE-bpKQ";

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/unit_tests/deep_links/video_deep_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::convert::TryFrom;
use std::str::FromStr;
use url::Url;

const STREAMING_SERVER_URL: &str = "http://127.0.0.1:11471/";
const STREAMING_SERVER_URL: &str = "http://127.0.0.1:11470/";
const YT_ID: &str = "aqz-KE-bpKQ";

#[test]
Expand Down

0 comments on commit 1f78803

Please sign in to comment.