fix: handle empty artists

This commit is contained in:
ThetaDev 2023-02-08 21:38:58 +01:00
parent f98c85b385
commit 3574a44b77
2 changed files with 10 additions and 9 deletions

View file

@ -191,14 +191,15 @@ fn map_artist_page(
}
}
let mut content = res.contents.single_column_browse_results_renderer.contents;
let sections = content
.try_swap_remove(0)
.ok_or(ExtractionError::InvalidData(Cow::Borrowed("no content")))?
.tab_renderer
.content
.section_list_renderer
.contents;
let sections = res
.contents
.single_column_browse_results_renderer
.contents
.into_iter()
.next()
.and_then(|tab| tab.tab_renderer.content)
.map(|c| c.section_list_renderer.contents)
.unwrap_or_default();
let mut mapper = MusicListMapper::with_artist(
lang,

View file

@ -14,7 +14,7 @@ use super::{
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct MusicArtist {
pub contents: SingleColumnBrowseResult<Tab<SectionList<ItemSection>>>,
pub contents: SingleColumnBrowseResult<Tab<Option<SectionList<ItemSection>>>>,
pub header: Header,
}