Stream::youtube impl
+use crate::constants::YOUTUBE_ADDON_ID_PREFIX;
use crate::types::resource::Subtitles;
+use boolinator::Boolinator;
#[cfg(test)]
use derivative::Derivative;
use magnet_url::Magnet;
@@ -51,6 +53,23 @@ impl Stream {
_ => None,
}
}
+ pub fn youtube(video_id: &str) -> Option<Self> {
+ video_id
+ .starts_with(YOUTUBE_ADDON_ID_PREFIX)
+ .as_option()
+ // video id is in format: yt_id:YT_CHANNEL_ID:YT_VIDEO_ID
+ .and_then(|_| video_id.split(':').nth(2))
+ .map(|yt_id| Self {
+ source: StreamSource::YouTube {
+ yt_id: yt_id.to_owned(),
+ },
+ name: None,
+ description: None,
+ thumbnail: None,
+ subtitles: vec![],
+ behavior_hints: Default::default(),
+ })
+ }
}
#[derive(Clone, PartialEq, Serialize, Deserialize)]
