Fix get_artist_singles year field (closes #163)

This commit is contained in:
sigma67 2021-01-29 17:57:50 +01:00
commit a011491cfe
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
2 changed files with 7 additions and 3 deletions

View file

@ -302,7 +302,7 @@ class BrowsingMixin:
: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}

View file

@ -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)
@ -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)