Skip to content

Commit

Permalink
fix #675
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Dec 17, 2024
1 parent fe95f59 commit 2cef1d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tests/mixins/test_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,26 @@ def test_get_album(self, yt, yt_auth, sample_album):
assert album["tracks"][0]["isExplicit"]
assert all(item["views"] is not None for item in album["tracks"])
assert all(item["album"] is not None for item in album["tracks"])
assert album["likeStatus"] is not None
assert album["audioPlaylistId"] is not None
assert album["tracks"][0]["trackNumber"] == 1
assert "feedbackTokens" in album["tracks"][0]
album = yt.get_album("MPREb_BQZvl3BFGay")
assert album["audioPlaylistId"] is not None
assert len(album["tracks"]) == 7
assert len(album["tracks"][0]["artists"]) == 1
album = yt.get_album("MPREb_rqH94Zr3NN0")
assert album["likeStatus"] is not None
assert album["audioPlaylistId"] is not None
assert len(album["tracks"][0]["artists"]) == 2
album = yt.get_album("MPREb_TPH4WqN5pUo") # album with tracks completely removed/missing
assert album["likeStatus"] is not None
assert album["audioPlaylistId"] is not None
assert album["tracks"][0]["trackNumber"] == 3
assert album["tracks"][13]["trackNumber"] == 18
album = yt.get_album("MPREb_YuigcYm2erf") # album with track (#8) disabled/greyed out
assert album["likeStatus"] is not None
assert album["audioPlaylistId"] is not None
assert album["tracks"][7]["trackNumber"] is None

def test_get_album_errors(self, yt):
Expand Down
5 changes: 3 additions & 2 deletions ytmusicapi/parsers/albums.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ def parse_album_header_2024(response):
# add to library/uploaded
buttons = header["buttons"]
album["audioPlaylistId"] = nav(
buttons, [1, "musicPlayButtonRenderer", "playNavigationEndpoint", *WATCH_PLAYLIST_ID], True
find_object_by_key(buttons, "musicPlayButtonRenderer"), ["musicPlayButtonRenderer", "playNavigationEndpoint", *WATCH_PLAYLIST_ID], True
)
service = nav(buttons, [0, "toggleButtonRenderer", "defaultServiceEndpoint"], True)
service = nav(find_object_by_key(buttons, "toggleButtonRenderer"), ["toggleButtonRenderer", "defaultServiceEndpoint"], True)
album["likeStatus"] = "INDIFFERENT"
if service:
album["likeStatus"] = parse_like_status(service)

Expand Down

0 comments on commit 2cef1d6

Please sign in to comment.