Fix bugs in playlist parsing (unavailable and uploaded songs) (closes #30)

This commit is contained in:
sigma67 2020-06-18 12:48:42 +02:00
commit 93d744897f
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0

View file

@ -110,6 +110,7 @@ def parse_playlist_items(results):
try:
# if playlist is not owned, the playlist item can't be interacted with
videoId = setVideoId = None
like = None
# if item is not playable, there is no videoId
if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON):
@ -123,6 +124,9 @@ def parse_playlist_items(results):
item, MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['setVideoId']
break
if 'menu' in data:
like = nav(data, MENU_LIKE_STATUS)
title = get_item_text(data, 0)
if title == 'Song deleted':
continue
@ -141,10 +145,6 @@ def parse_playlist_items(results):
duration = data['fixedColumns'][0][
'musicResponsiveListItemFixedColumnRenderer']['text']['runs'][0]['text']
like = None
if 'menu' in data and 'topLevelButtons' in nav(data, MENU):
like = nav(data, MENU_LIKE_STATUS)
thumbnails = None
if 'thumbnail' in data:
thumbnails = nav(data, THUMBNAILS)
@ -255,6 +255,8 @@ def parse_search_result(data, resultType=None):
def parse_song_artists(data, index):
flex_item = get_flex_column_item(data, index)
if not flex_item:
return None
artists = []
for j in range(int(len(flex_item['text']['runs']) / 2) + 1):
artists.append({