sigma67/ytmusicapi

`get_album` doesn't fetch `audioPlaylistId` for some albums

Closed this issue · 2 comments

Describe the bug
get_album doesn't fetch audioPlaylistId for some albums. whether it is authenticated or not, both fail

To Reproduce

from ytmusicapi import YTMusic


ytmusic = YTMusic("oauth.json")
ytmusic2 = YTMusic()

browse_id = "MPREb_6egF9klMJg7"

album_details = ytmusic.get_album(browse_id)
print(album_details['audioPlaylistId'])

album_details = ytmusic2.get_album(browse_id)
print(album_details['audioPlaylistId'])

# verify that a playlist id for this album does exist
expected_playlist_id = "OLAK5uy_k8nXdYeGt9_ES_a_n-UHkL2W3n2coCR_4"
fetched_browse_id = ytmusic.get_album_browse_id(expected_playlist_id)
assert fetched_browse_id == browse_id

prints

None
None

with the assert passing

It looks like a problem with the the function parse_album_header_2024(response) in albums.py

This line specifically: album["audioPlaylistId"] = nav( buttons, [1, "musicPlayButtonRenderer", "playNavigationEndpoint", *WATCH_PLAYLIST_ID], True )

The code expects *WATCH_PLAYLIST_ID to be in buttons, but it actually has *WATCH_PID.

This always happens when the button order changes. Will need to use a different approach to find the correct one.