get_charts: fix unavailable song error in trending section

This commit is contained in:
sigma67 2022-01-30 14:50:41 +01:00
commit 2e8c09a430
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
3 changed files with 15 additions and 9 deletions

View file

@ -43,12 +43,13 @@ def parse_chart_artist(data):
def parse_chart_trending(data):
flex_0 = get_flex_column_item(data, 0)
artists = parse_song_artists(data, 1)
views = artists.pop() # last item is views for some reason
views = views['name'].split(' ')[0]
index = get_dot_separator_index(artists)
# last item is views for some reason
views = None if index == len(artists) else artists.pop()['name'].split(' ')[0]
return {
'title': nav(flex_0, TEXT_RUN_TEXT),
'videoId': nav(flex_0, TEXT_RUN + NAVIGATION_VIDEO_ID),
'playlistId': nav(flex_0, TEXT_RUN + NAVIGATION_PLAYLIST_ID),
'videoId': nav(flex_0, TEXT_RUN + NAVIGATION_VIDEO_ID, True),
'playlistId': nav(flex_0, TEXT_RUN + NAVIGATION_PLAYLIST_ID, True),
'artists': artists,
'thumbnails': nav(data, THUMBNAILS),
'views': views