use yt stream in external_player deep link too
@@ -177,6 +177,13 @@ pub struct VideoDeepLinks {
impl From<(&Video, &ResourceRequest)> for VideoDeepLinks {
fn from((video, request): (&Video, &ResourceRequest)) -> Self {
+ let stream = video
+ .streams
+ .iter()
+ .exactly_one()
+ .ok()
+ .map(Cow::Borrowed)
+ .or_else(|| Stream::youtube(&video.id).map(Cow::Owned));
VideoDeepLinks {
meta_details_streams: format!(
"stremio:///metadetails/{}/{}/{}",
@@ -184,14 +191,7 @@ impl From<(&Video, &ResourceRequest)> for VideoDeepLinks {
utf8_percent_encode(&request.path.id, URI_COMPONENT_ENCODE_SET),
utf8_percent_encode(&video.id, URI_COMPONENT_ENCODE_SET)
),
- player: video
- .streams
- .iter()
- .exactly_one()
- .ok()
- .map(Cow::Borrowed)
- .or_else(|| Stream::youtube(&video.id).map(Cow::Owned))
- .map(|stream| {
+ player: stream.as_ref().map(|stream| {
format!(
"stremio:///player/{}/{}/{}/{}/{}/{}",
utf8_percent_encode(
@@ -207,12 +207,9 @@ impl From<(&Video, &ResourceRequest)> for VideoDeepLinks {
utf8_percent_encode(&video.id, URI_COMPONENT_ENCODE_SET)
)
}),
- external_player: video
- .streams
- .iter()
- .exactly_one()
- .ok()
- .map(ExternalPlayerLink::from),
+ external_player: stream
+ .as_ref()
+ .map(|stream| ExternalPlayerLink::from(stream.as_ref())),
}
}
}
