Skip to content

Commit

Permalink
Fix get_artist_singles year field (closes #163)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Jan 29, 2021
1 parent 2857e22 commit a011491
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ytmusicapi/mixins/browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def get_artist_albums(self, channelId: str, params: str) -> List[Dict]:
:param channelId: channel Id of the artist
:param params: params obtained by :py:func:`get_artist`
:return: List of albums in the format of :py:func:`get_library_albums`,
except artist key is missing.
except artists key is missing.
"""
body = {"browseId": channelId, "params": params}
Expand Down
8 changes: 6 additions & 2 deletions ytmusicapi/parsers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ def parse_albums(results):
album = {}
album['browseId'] = nav(data, TITLE + NAVIGATION_BROWSE_ID)
album['title'] = nav(data, TITLE_TEXT)
album['type'] = nav(data, SUBTITLE)
album['thumbnails'] = nav(data, THUMBNAIL_RENDERER)
album['artists'] = []
run_count = len(data['subtitle']['runs'])
has_artists = False
if run_count == 1:
album['year'] = nav(data, SUBTITLE)
else:
album['type'] = nav(data, SUBTITLE)

if run_count == 3:
if nav(data, SUBTITLE2).isdigit():
album['year'] = nav(data, SUBTITLE2)
Expand All @@ -46,6 +49,7 @@ def parse_albums(results):

if has_artists:
subtitle = data['subtitle']['runs'][2]
album['artists'] = []
album['artists'].append({
'name': subtitle['text'],
'id': nav(subtitle, NAVIGATION_BROWSE_ID, True)
Expand Down

0 comments on commit a011491

Please sign in to comment.