diff --git a/src/client/mod.rs b/src/client/mod.rs index a8bd5d4..3bbb724 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -216,6 +216,17 @@ static CLIENT_VERSION_REGEX: Lazy = static VISITOR_DATA_REGEX: Lazy = Lazy::new(|| Regex::new(r#""visitorData":"([\w\d_\-%]+?)""#).unwrap()); +/// Default order of client types when fetching player data +/// +/// The order may change in the future in case YouTube applies changes to their +/// platform that disable a client or make it less reliable. +pub const DEFAULT_PLAYER_CLIENT_ORDER: &[ClientType] = &[ + ClientType::Tv, + ClientType::TvHtml5Embed, + ClientType::Android, + ClientType::Ios, +]; + /// The RustyPipe client used to access YouTube's API /// /// RustyPipe uses an [`Arc`] internally, so if you are using the client diff --git a/src/client/player.rs b/src/client/player.rs index 2e766e7..b78a15c 100644 --- a/src/client/player.rs +++ b/src/client/player.rs @@ -25,6 +25,7 @@ use super::{ player::{self, Format}, }, ClientType, MapRespCtx, MapResponse, MapResult, RustyPipeQuery, YTContext, + DEFAULT_PLAYER_CLIENT_ORDER, }; #[derive(Debug, Serialize)] @@ -65,7 +66,7 @@ struct QContentPlaybackContext<'a> { impl RustyPipeQuery { /// Get YouTube player data (video/audio streams + basic metadata) pub async fn player + Debug>(&self, video_id: S) -> Result { - self.player_from_clients(video_id, &[ClientType::Desktop, ClientType::TvHtml5Embed]) + self.player_from_clients(video_id, DEFAULT_PLAYER_CLIENT_ORDER) .await }