Skip to content

Commit

Permalink
Merge pull request #664 from Stremio/fix/next-video-stream
Browse files Browse the repository at this point in the history
Fix next video stream
  • Loading branch information
elpiel authored Mar 25, 2024
2 parents 0aa449d + f6cbe73 commit 542bfb1
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 253 deletions.
48 changes: 48 additions & 0 deletions src/deep_links/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,54 @@ impl From<(&Video, &ResourceRequest, &Option<Url>, &Settings)> for VideoDeepLink
}
}

impl
From<(
&Video,
&ResourceRequest,
&ResourceRequest,
&Option<Url>,
&Settings,
)> for VideoDeepLinks
{
fn from(
(video, stream_request, meta_request, streaming_server_url, settings): (
&Video,
&ResourceRequest,
&ResourceRequest,
&Option<Url>,
&Settings,
),
) -> Self {
let stream = video.stream();
VideoDeepLinks {
meta_details_streams: format!(
"stremio:///detail/{}/{}/{}",
utf8_percent_encode(&meta_request.path.r#type, URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(&meta_request.path.id, URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(&video.id, URI_COMPONENT_ENCODE_SET)
),
player: stream
.as_ref()
.map(|stream| {
Ok::<_, anyhow::Error>(format!(
"stremio:///player/{}/{}/{}/{}/{}/{}",
utf8_percent_encode(&stream.encode()?, URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(stream_request.base.as_str(), URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(meta_request.base.as_str(), URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(&meta_request.path.r#type, URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(&meta_request.path.id, URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(&video.id, URI_COMPONENT_ENCODE_SET)
))
})
.transpose()
.unwrap_or_else(|error| Some(ErrorLink::from(error).into())),
external_player: stream.as_ref().map(|stream| {
ExternalPlayerLink::from((stream.as_ref(), streaming_server_url, settings))
}),
}
}
}

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StreamDeepLinks {
Expand Down
Loading

0 comments on commit 542bfb1

Please sign in to comment.