diff --git a/src/client/channel.rs b/src/client/channel.rs index 9584697..58cdf85 100644 --- a/src/client/channel.rs +++ b/src/client/channel.rs @@ -16,7 +16,9 @@ use crate::{ util::{self, timeago, ProtoBuilder}, }; -use super::{response, ClientType, MapRespCtx, MapResponse, QContinuation, RustyPipeQuery}; +use super::{ + response, ClientType, MapRespCtx, MapRespOptions, MapResponse, QContinuation, RustyPipeQuery, +}; #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -178,12 +180,16 @@ impl RustyPipeQuery { continuation: &channel_info_ctoken(channel_id, &random_target()), }; - self.execute_request::( + self.execute_request_ctx::( ClientType::Desktop, "channel_info", channel_id, "browse", &request_body, + MapRespOptions { + unlocalized: true, + ..Default::default() + }, ) .await } diff --git a/src/client/mod.rs b/src/client/mod.rs index a2410cc..f1b49b3 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -1820,7 +1820,7 @@ impl RustyPipeQuery { id: &str, endpoint: &str, body: &B, - ctx_src: MapRespCtxSource<'_>, + ctx_src: MapRespOptions<'_>, ) -> Result { tracing::debug!("getting {}({})", operation, id); @@ -1946,7 +1946,7 @@ impl RustyPipeQuery { id, endpoint, body, - MapRespCtxSource::default(), + MapRespOptions::default(), ) .await } @@ -1989,6 +1989,7 @@ impl AsRef for RustyPipeQuery { } } +/// Additional data needed for mapping YouTube responses struct MapRespCtx<'a> { id: &'a str, lang: Language, @@ -1998,8 +1999,10 @@ struct MapRespCtx<'a> { artist: Option, } +/// Options to give to the mapper when making requests; +/// used to construct the [`MapRespCtx`] #[derive(Default)] -struct MapRespCtxSource<'a> { +struct MapRespOptions<'a> { visitor_data: Option<&'a str>, deobf: Option<&'a DeobfData>, artist: Option, diff --git a/src/client/music_artist.rs b/src/client/music_artist.rs index 35728c1..99e86ce 100644 --- a/src/client/music_artist.rs +++ b/src/client/music_artist.rs @@ -5,7 +5,7 @@ use regex::Regex; use tracing::debug; use crate::{ - client::{response::url_endpoint::NavigationEndpoint, MapRespCtxSource, QContinuation}, + client::{response::url_endpoint::NavigationEndpoint, MapRespOptions, QContinuation}, error::{Error, ExtractionError}, model::{ paginator::Paginator, traits::FromYtItem, AlbumItem, ArtistId, MusicArtist, MusicItem, @@ -109,7 +109,7 @@ impl RustyPipeQuery { artist_id, "browse", &request_body, - MapRespCtxSource { + MapRespOptions { artist: Some(first_page.artist.clone()), visitor_data: first_page.visitor_data.as_deref(), ..Default::default() diff --git a/src/client/pagination.rs b/src/client/pagination.rs index f656bab..4a3c166 100644 --- a/src/client/pagination.rs +++ b/src/client/pagination.rs @@ -10,7 +10,7 @@ use crate::serializer::MapResult; use super::response::music_item::{map_queue_item, MusicListMapper, PlaylistPanelVideo}; use super::{ - response, ClientType, MapRespCtx, MapRespCtxSource, MapResponse, QContinuation, RustyPipeQuery, + response, ClientType, MapRespCtx, MapRespOptions, MapResponse, QContinuation, RustyPipeQuery, }; impl RustyPipeQuery { @@ -35,7 +35,7 @@ impl RustyPipeQuery { ctoken, endpoint.as_str(), &request_body, - MapRespCtxSource { + MapRespOptions { visitor_data, ..Default::default() }, @@ -55,7 +55,7 @@ impl RustyPipeQuery { ctoken, endpoint.as_str(), &request_body, - MapRespCtxSource { + MapRespOptions { visitor_data, ..Default::default() }, diff --git a/src/client/player.rs b/src/client/player.rs index e4961aa..9d9ee5e 100644 --- a/src/client/player.rs +++ b/src/client/player.rs @@ -24,7 +24,7 @@ use super::{ self, player::{self, Format}, }, - ClientType, MapRespCtx, MapRespCtxSource, MapResponse, MapResult, RustyPipeQuery, + ClientType, MapRespCtx, MapRespOptions, MapResponse, MapResult, RustyPipeQuery, DEFAULT_PLAYER_CLIENT_ORDER, }; @@ -159,8 +159,9 @@ impl RustyPipeQuery { video_id, "player", &request_body, - MapRespCtxSource { + MapRespOptions { deobf: Some(&deobf), + unlocalized: true, ..Default::default() }, )