fix: fetch artist albums continuation
This commit is contained in:
parent
bef2fc3df6
commit
93dbd0d20c
17 changed files with 50309 additions and 38906 deletions
|
|
@ -10,7 +10,9 @@ use crate::model::{
|
|||
use crate::serializer::MapResult;
|
||||
|
||||
use super::response::music_item::{map_queue_item, MusicListMapper, PlaylistPanelVideo};
|
||||
use super::{response, ClientType, MapRespCtx, MapResponse, QContinuation, RustyPipeQuery};
|
||||
use super::{
|
||||
response, ClientType, MapRespCtx, MapRespCtxSource, MapResponse, QContinuation, RustyPipeQuery,
|
||||
};
|
||||
|
||||
impl RustyPipeQuery {
|
||||
/// Get more YouTube items from the given continuation token and endpoint
|
||||
|
|
@ -37,13 +39,13 @@ impl RustyPipeQuery {
|
|||
};
|
||||
|
||||
let p = self
|
||||
.execute_request_vdata::<response::MusicContinuation, Paginator<MusicItem>, _>(
|
||||
.execute_request_ctx::<response::MusicContinuation, Paginator<MusicItem>, _>(
|
||||
ClientType::DesktopMusic,
|
||||
"music_continuation",
|
||||
ctoken,
|
||||
endpoint.as_str(),
|
||||
&request_body,
|
||||
Some(&visitor_data),
|
||||
MapRespCtxSource::visitor_data(&visitor_data),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
|
@ -138,7 +140,11 @@ impl MapResponse<Paginator<MusicItem>> for response::MusicContinuation {
|
|||
self,
|
||||
ctx: &MapRespCtx<'_>,
|
||||
) -> Result<MapResult<Paginator<MusicItem>>, ExtractionError> {
|
||||
let mut mapper = MusicListMapper::new(ctx.lang);
|
||||
let mut mapper = if let Some(artist) = &ctx.artist {
|
||||
MusicListMapper::with_artist(ctx.lang, artist.clone())
|
||||
} else {
|
||||
MusicListMapper::new(ctx.lang)
|
||||
};
|
||||
let mut continuations = Vec::new();
|
||||
|
||||
match self.continuation_contents {
|
||||
|
|
@ -156,7 +162,11 @@ impl MapResponse<Paginator<MusicItem>> for response::MusicContinuation {
|
|||
response::music_item::ItemSection::MusicCarouselShelfRenderer(shelf) => {
|
||||
mapper.map_response(shelf.contents);
|
||||
}
|
||||
_ => {}
|
||||
response::music_item::ItemSection::GridRenderer(mut grid) => {
|
||||
mapper.map_response(grid.items);
|
||||
continuations.append(&mut grid.continuations);
|
||||
}
|
||||
response::music_item::ItemSection::None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -173,6 +183,10 @@ impl MapResponse<Paginator<MusicItem>> for response::MusicContinuation {
|
|||
}
|
||||
});
|
||||
}
|
||||
Some(response::music_item::ContinuationContents::GridContinuation(mut grid)) => {
|
||||
mapper.map_response(grid.items);
|
||||
continuations.append(&mut grid.continuations);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +271,19 @@ impl<T: FromYtItem> Paginator<T> {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Extend the items of the paginator until the paginator is exhausted.
|
||||
pub async fn extend_all<Q: AsRef<RustyPipeQuery>>(&mut self, query: Q) -> Result<(), Error> {
|
||||
let query = query.as_ref();
|
||||
loop {
|
||||
match self.extend(query).await {
|
||||
Ok(false) => break,
|
||||
Err(e) => return Err(e),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Paginator<Comment> {
|
||||
|
|
@ -334,6 +361,22 @@ macro_rules! paginator {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Extend the items of the paginator until the paginator is exhausted.
|
||||
pub async fn extend_all<Q: AsRef<RustyPipeQuery>>(
|
||||
&mut self,
|
||||
query: Q,
|
||||
) -> Result<(), Error> {
|
||||
let query = query.as_ref();
|
||||
loop {
|
||||
match self.extend(query).await {
|
||||
Ok(false) => break,
|
||||
Err(e) => return Err(e),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue