Add options to get drm dash and hls url with search

This commit is contained in:
bytedream 2023-09-06 02:55:04 +02:00
parent 18f891efd2
commit b477ca982c
2 changed files with 22 additions and 8 deletions

View file

@ -87,7 +87,9 @@ pub struct Search {
///
/// stream.locale → Stream locale/language
/// stream.dash_url → Stream url in DASH format
/// stream.drm_dash_url → Stream url in DRM protected DASH format
/// stream.hls_url → Stream url in HLS format
/// stream.drm_hls_url → Stream url in DRM protected HLS format
///
/// subtitle.locale → Subtitle locale/language
/// subtitle.url → Url to the subtitle

View file

@ -163,17 +163,27 @@ impl From<&Concert> for FormatConcert {
struct FormatStream {
pub locale: Locale,
pub dash_url: String,
pub drm_dash_url: String,
pub hls_url: String,
pub drm_hls_url: String,
}
impl From<&Stream> for FormatStream {
fn from(value: &Stream) -> Self {
let (dash_url, hls_url) = value.variants.get(&Locale::Custom("".to_string())).map_or(
("".to_string(), "".to_string()),
let (dash_url, drm_dash_url, hls_url, drm_hls_url) =
value.variants.get(&Locale::Custom("".to_string())).map_or(
(
"".to_string(),
"".to_string(),
"".to_string(),
"".to_string(),
),
|v| {
(
v.adaptive_dash.clone().unwrap_or_default().url,
v.drm_adaptive_dash.clone().unwrap_or_default().url,
v.adaptive_hls.clone().unwrap_or_default().url,
v.drm_adaptive_hls.clone().unwrap_or_default().url,
)
},
);
@ -181,7 +191,9 @@ impl From<&Stream> for FormatStream {
Self {
locale: value.audio_locale.clone(),
dash_url,
drm_dash_url,
hls_url,
drm_hls_url,
}
}
}