StreamBehaviorHints struct defined
@@ -3,6 +3,7 @@ use crate::types::resource::Subtitles;
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use serde_hex::{SerHex, Strict};
+use std::collections::HashMap;
use url::Url;
#[derive(Clone, PartialEq, Serialize, Deserialize)]
@@ -17,8 +18,8 @@ pub struct Stream {
pub thumbnail: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub subtitles: Vec<Subtitles>,
- #[serde(default, skip_serializing_if = "serde_json::Map::is_empty")]
- pub behavior_hints: serde_json::Map<String, serde_json::Value>,
+ #[serde(default, skip_serializing_if = "is_default_value")]
+ pub behavior_hints: StreamBehaviorHints,
}
#[derive(Clone, PartialEq, Serialize, Deserialize)]
@@ -49,3 +50,21 @@ pub enum StreamSource {
player_frame_url: Url,
},
}
+
+#[derive(Default, Clone, PartialEq, Serialize, Deserialize)]
+#[cfg_attr(test, derive(Debug))]
+#[serde(rename_all = "camelCase")]
+pub struct StreamBehaviorHints {
+ #[serde(default, skip_serializing_if = "is_default_value")]
+ pub not_web_ready: bool,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub binge_group: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub country_whitelist: Option<Vec<String>>,
+ #[serde(default, skip_serializing_if = "HashMap::is_empty")]
+ pub headers: HashMap<String, String>,
+}
+
+fn is_default_value<T: Default + PartialEq>(value: &T) -> bool {
+ *value == T::default()
+}
