Skip to content

Commit

Permalink
fix(yt_music): handling potential multiple tabs in response
Browse files Browse the repository at this point in the history
  • Loading branch information
SilentVoid13 committed Dec 19, 2024
1 parent 35576a6 commit f5590ab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sync_dis_boi"
version = "0.4.0"
version = "0.5.2"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn main() -> Result<()> {
match args.src.get_dst() {
MusicPlatformDst::Export { dest, minify } => {
export(src_api, dest, *minify).await?;
},
}
_ => {
let dst_api = args.src.get_dst().parse(&args, &config_dir).await?;
synchronize(src_api, dst_api, args.config).await?;
Expand Down
14 changes: 8 additions & 6 deletions src/yt_music/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ impl YtMusicResponse {
}

pub fn get_card_shelf(&mut self) -> Option<&mut MusicCardShelfRenderer> {
self.get_section_renderer_content()?.music_card_shelf_renderer.as_mut()
self.get_section_renderer_content()?
.music_card_shelf_renderer
.as_mut()
}

pub fn get_mrlirs(&mut self) -> Option<Vec<&MusicResponsiveListItemRenderer>> {
Expand Down Expand Up @@ -78,7 +80,8 @@ impl YtMusicResponse {

pub fn get_section_renderer_content(&mut self) -> Option<&mut SectionRendererContent> {
if let Some(sr) = self.contents.single_column_browse_results_renderer.as_mut() {
sr.tabs[0]
sr.tabs
.first_mut()?
.tab_renderer
.content
.section_list_renderer
Expand All @@ -89,7 +92,8 @@ impl YtMusicResponse {
item.music_playlist_shelf_renderer.is_some() || item.grid_renderer.is_some()
})
} else if let Some(tr) = self.contents.tabbed_search_results_renderer.as_mut() {
tr.tabs[0]
tr.tabs
.first_mut()?
.tab_renderer
.content
.section_list_renderer
Expand Down Expand Up @@ -164,12 +168,11 @@ pub struct ResponseContent {
#[serde(rename_all = "camelCase")]
pub struct TwoColumnBrowseResultsRenderer {
pub secondary_contents: TabRendererContent,
pub tabs: [Tab; 1],
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SingleColumnBrowseResultsRenderer {
pub tabs: [Tab; 1],
pub tabs: Vec<Tab>,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -274,7 +277,6 @@ impl MusicResponsiveListItemRenderer {

pub type MusicCardShelfRenderer = MusicTwoRowItemRenderer;


#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ItemSectionRendererContent {
Expand Down

0 comments on commit f5590ab

Please sign in to comment.