Skip to content

Commit

Permalink
Update get_library_albums parsing to new YT Web display format (closes
Browse files Browse the repository at this point in the history
…#84)

Change 'artists' key to dict with name/id
  • Loading branch information
sigma67 committed Sep 28, 2020
1 parent 14daa31 commit 5a10329
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 15 additions & 1 deletion ytmusicapi/mixins/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,21 @@ def get_library_albums(self, limit: int = 25) -> List[Dict]:
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'}
Expand Down
8 changes: 5 additions & 3 deletions ytmusicapi/parsers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5a10329

Please sign in to comment.