Skip to content

Commit

Permalink
fix get_album other_versions attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Jul 3, 2024
1 parent 11823d6 commit f4f9e7c
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions ytmusicapi/mixins/browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
get_reloadable_continuation_params,
)
from ytmusicapi.helpers import YTM_DOMAIN, sum_total_duration
from ytmusicapi.parsers.albums import parse_album_header, parse_album_header_2024
from ytmusicapi.parsers.albums import parse_album_header_2024
from ytmusicapi.parsers.browsing import parse_album, parse_content_list, parse_mixed_content, parse_playlist
from ytmusicapi.parsers.library import parse_albums
from ytmusicapi.parsers.playlists import parse_playlist_items
Expand Down Expand Up @@ -515,19 +515,16 @@ def get_album(self, browseId: str) -> Dict:
body = {"browseId": browseId}
endpoint = "browse"
response = self._send_request(endpoint, body)
if "header" in response:
album = parse_album_header(response)
else:
album = parse_album_header_2024(response)
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + MUSIC_SHELF, True) or nav(
# fallback for 2024 format
response,
[*TWO_COLUMN_RENDERER, "secondaryContents", *SECTION_LIST_ITEM, *MUSIC_SHELF],
)
album = parse_album_header_2024(response)

results = nav(response, [*TWO_COLUMN_RENDERER, "secondaryContents", *SECTION_LIST_ITEM, *MUSIC_SHELF])
album["tracks"] = parse_playlist_items(results["contents"], is_album=True)
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST + [1] + CAROUSEL, True)
if results is not None:
album["other_versions"] = parse_content_list(results["contents"], parse_album)

other_versions = nav(
response, [*TWO_COLUMN_RENDERER, "secondaryContents", *SECTION_LIST, 1, *CAROUSEL]
)
if other_versions is not None:
album["other_versions"] = parse_content_list(other_versions["contents"], parse_album)
album["duration_seconds"] = sum_total_duration(album)
for i, track in enumerate(album["tracks"]):
album["tracks"][i]["album"] = album["title"]
Expand Down

0 comments on commit f4f9e7c

Please sign in to comment.