Update get_library_albums parsing to new YT Web display format (closes #84)

Change 'artists' key to dict with name/id
This commit is contained in:
sigma67 2020-09-28 14:45:25 +02:00
commit 5a1032983d
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
2 changed files with 20 additions and 4 deletions

View file

@ -92,7 +92,21 @@ class LibraryMixin:
Gets the albums in the user's library.
:param limit: Number of albums to return
:return: List of albums
:return: List of albums.
Each item is in the following format:
{
"browseId": "MPREb_G8AiyN7RvFg",
"title": "Beautiful",
"type": "Album",
"thumbnails": [...],
"artists": {
"name": "Project 46",
"id": "UCXFv36m62USAN5rnVct9B4g"
},
"year": "2015"
}
"""
self._check_auth()
body = {'browseId': 'FEmusic_liked_albums'}

View file

@ -51,9 +51,11 @@ def parse_albums(results, upload=True):
'id': nav(subtitle, NAVIGATION_BROWSE_ID)
})
else:
album['artists'] = nav(data, SUBTITLE)
album['year'] = nav(data, SUBTITLE2)
album['trackCount'] = nav(data, SUBTITLE3).split(' ')[0]
album['artists'] = {
'name': nav(data, SUBTITLE2),
'id': nav(data, ['subtitle', 'runs', 2] + NAVIGATION_BROWSE_ID, True)
}
album['year'] = nav(data, SUBTITLE3)
albums.append(album)