fix: fetch unlocalized player data to interpret errors correctly; regression introduced with v0.6.0

This commit is contained in:
ThetaDev 2024-11-09 03:00:04 +01:00
parent 957fa22f77
commit 40811a89e5
5 changed files with 22 additions and 12 deletions

View file

@ -16,7 +16,9 @@ use crate::{
util::{self, timeago, ProtoBuilder}, util::{self, timeago, ProtoBuilder},
}; };
use super::{response, ClientType, MapRespCtx, MapResponse, QContinuation, RustyPipeQuery}; use super::{
response, ClientType, MapRespCtx, MapRespOptions, MapResponse, QContinuation, RustyPipeQuery,
};
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
@ -178,12 +180,16 @@ impl RustyPipeQuery {
continuation: &channel_info_ctoken(channel_id, &random_target()), continuation: &channel_info_ctoken(channel_id, &random_target()),
}; };
self.execute_request::<response::ChannelAbout, _, _>( self.execute_request_ctx::<response::ChannelAbout, _, _>(
ClientType::Desktop, ClientType::Desktop,
"channel_info", "channel_info",
channel_id, channel_id,
"browse", "browse",
&request_body, &request_body,
MapRespOptions {
unlocalized: true,
..Default::default()
},
) )
.await .await
} }

View file

@ -1820,7 +1820,7 @@ impl RustyPipeQuery {
id: &str, id: &str,
endpoint: &str, endpoint: &str,
body: &B, body: &B,
ctx_src: MapRespCtxSource<'_>, ctx_src: MapRespOptions<'_>,
) -> Result<M, Error> { ) -> Result<M, Error> {
tracing::debug!("getting {}({})", operation, id); tracing::debug!("getting {}({})", operation, id);
@ -1946,7 +1946,7 @@ impl RustyPipeQuery {
id, id,
endpoint, endpoint,
body, body,
MapRespCtxSource::default(), MapRespOptions::default(),
) )
.await .await
} }
@ -1989,6 +1989,7 @@ impl AsRef<RustyPipeQuery> for RustyPipeQuery {
} }
} }
/// Additional data needed for mapping YouTube responses
struct MapRespCtx<'a> { struct MapRespCtx<'a> {
id: &'a str, id: &'a str,
lang: Language, lang: Language,
@ -1998,8 +1999,10 @@ struct MapRespCtx<'a> {
artist: Option<ArtistId>, artist: Option<ArtistId>,
} }
/// Options to give to the mapper when making requests;
/// used to construct the [`MapRespCtx`]
#[derive(Default)] #[derive(Default)]
struct MapRespCtxSource<'a> { struct MapRespOptions<'a> {
visitor_data: Option<&'a str>, visitor_data: Option<&'a str>,
deobf: Option<&'a DeobfData>, deobf: Option<&'a DeobfData>,
artist: Option<ArtistId>, artist: Option<ArtistId>,

View file

@ -5,7 +5,7 @@ use regex::Regex;
use tracing::debug; use tracing::debug;
use crate::{ use crate::{
client::{response::url_endpoint::NavigationEndpoint, MapRespCtxSource, QContinuation}, client::{response::url_endpoint::NavigationEndpoint, MapRespOptions, QContinuation},
error::{Error, ExtractionError}, error::{Error, ExtractionError},
model::{ model::{
paginator::Paginator, traits::FromYtItem, AlbumItem, ArtistId, MusicArtist, MusicItem, paginator::Paginator, traits::FromYtItem, AlbumItem, ArtistId, MusicArtist, MusicItem,
@ -109,7 +109,7 @@ impl RustyPipeQuery {
artist_id, artist_id,
"browse", "browse",
&request_body, &request_body,
MapRespCtxSource { MapRespOptions {
artist: Some(first_page.artist.clone()), artist: Some(first_page.artist.clone()),
visitor_data: first_page.visitor_data.as_deref(), visitor_data: first_page.visitor_data.as_deref(),
..Default::default() ..Default::default()

View file

@ -10,7 +10,7 @@ use crate::serializer::MapResult;
use super::response::music_item::{map_queue_item, MusicListMapper, PlaylistPanelVideo}; use super::response::music_item::{map_queue_item, MusicListMapper, PlaylistPanelVideo};
use super::{ use super::{
response, ClientType, MapRespCtx, MapRespCtxSource, MapResponse, QContinuation, RustyPipeQuery, response, ClientType, MapRespCtx, MapRespOptions, MapResponse, QContinuation, RustyPipeQuery,
}; };
impl RustyPipeQuery { impl RustyPipeQuery {
@ -35,7 +35,7 @@ impl RustyPipeQuery {
ctoken, ctoken,
endpoint.as_str(), endpoint.as_str(),
&request_body, &request_body,
MapRespCtxSource { MapRespOptions {
visitor_data, visitor_data,
..Default::default() ..Default::default()
}, },
@ -55,7 +55,7 @@ impl RustyPipeQuery {
ctoken, ctoken,
endpoint.as_str(), endpoint.as_str(),
&request_body, &request_body,
MapRespCtxSource { MapRespOptions {
visitor_data, visitor_data,
..Default::default() ..Default::default()
}, },

View file

@ -24,7 +24,7 @@ use super::{
self, self,
player::{self, Format}, player::{self, Format},
}, },
ClientType, MapRespCtx, MapRespCtxSource, MapResponse, MapResult, RustyPipeQuery, ClientType, MapRespCtx, MapRespOptions, MapResponse, MapResult, RustyPipeQuery,
DEFAULT_PLAYER_CLIENT_ORDER, DEFAULT_PLAYER_CLIENT_ORDER,
}; };
@ -159,8 +159,9 @@ impl RustyPipeQuery {
video_id, video_id,
"player", "player",
&request_body, &request_body,
MapRespCtxSource { MapRespOptions {
deobf: Some(&deobf), deobf: Some(&deobf),
unlocalized: true,
..Default::default() ..Default::default()
}, },
) )