get_album: add album and artists to tracks (closes #257)

This commit is contained in:
sigma67 2022-02-10 11:24:05 +01:00
commit d046011b73
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0

View file

@ -441,34 +441,41 @@ class BrowsingMixin:
"title": "Revival", "title": "Revival",
"type": "Album", "type": "Album",
"thumbnails": [], "thumbnails": [],
"description": "Revival is the ninth studio album by American rapper Eminem. ...", "description": "Revival is the...",
"artists": [{ "artists": [
{
"name": "Eminem", "name": "Eminem",
"id": "UCedvOgsKFzcK3hA5taf3KoQ" "id": "UCedvOgsKFzcK3hA5taf3KoQ"
}], }
],
"year": "2017", "year": "2017",
"trackCount": 19, "trackCount": 19,
"duration": "1 hour, 17 minutes", "duration": "1 hour, 17 minutes",
"duration_seconds": 4657,
"audioPlaylistId": "OLAK5uy_nMr9h2VlS-2PULNz3M3XVXQj_P3C2bqaY", "audioPlaylistId": "OLAK5uy_nMr9h2VlS-2PULNz3M3XVXQj_P3C2bqaY",
"tracks": [ "tracks": [
{ {
"videoId": "iKLU7z_xdYQ", "videoId": "iKLU7z_xdYQ",
"title": "Walk On Water (feat. Beyoncé)", "title": "Walk On Water (feat. Beyoncé)",
"artists": None, "artists": [
"album": None,
"likeStatus": "INDIFFERENT",
"thumbnails": None,
"isAvailable": True,
"isExplicit": True,
"duration": "5:03",
"feedbackTokens":
{ {
"add": "AB9zfpJww...", "name": "Eminem",
"remove": "AB9zfpI807..." "id": "UCedvOgsKFzcK3hA5taf3KoQ"
}
],
"album": "Revival",
"likeStatus": "INDIFFERENT",
"thumbnails": null,
"isAvailable": true,
"isExplicit": true,
"duration": "5:03",
"duration_seconds": 303,
"feedbackTokens": {
"add": "AB9zfpK...",
"remove": "AB9zfpK..."
} }
} }
] ],
"duration_seconds": 4657
} }
""" """
body = {'browseId': browseId} body = {'browseId': browseId}
@ -478,6 +485,9 @@ class BrowsingMixin:
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + MUSIC_SHELF) results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + MUSIC_SHELF)
album['tracks'] = parse_playlist_items(results['contents']) album['tracks'] = parse_playlist_items(results['contents'])
album['duration_seconds'] = sum_total_duration(album) album['duration_seconds'] = sum_total_duration(album)
for i, track in enumerate(album['tracks']):
album['tracks'][i]['album'] = album['title']
album['tracks'][i]['artists'] = album['artists']
return album return album