Skip to content

Commit

Permalink
fixed KeyError in get_charts
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit yadav authored and sigma67 committed Sep 25, 2023
1 parent 56d54a2 commit f1141d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ytmusicapi/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
]
WATCH_VIDEO_ID = ['watchEndpoint', 'videoId']
NAVIGATION_VIDEO_ID = ['navigationEndpoint'] + WATCH_VIDEO_ID
QUEUE_VIDEO_ID = ['queueAddEndpoint','queueTarget','videoId']
NAVIGATION_VIDEO_ID_2 = MENU_ITEMS+[0]+MENU_SERVICE+QUEUE_VIDEO_ID
NAVIGATION_PLAYLIST_ID = ['navigationEndpoint', 'watchEndpoint', 'playlistId']
NAVIGATION_WATCH_PLAYLIST_ID = ['navigationEndpoint', 'watchPlaylistEndpoint', 'playlistId']
NAVIGATION_VIDEO_TYPE = [
Expand Down
5 changes: 4 additions & 1 deletion ytmusicapi/parsers/browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ def parse_song_flat(data):
def parse_video(result):
runs = nav(result, SUBTITLE_RUNS)
artists_len = get_dot_separator_index(runs)
videoId = nav(result, NAVIGATION_VIDEO_ID, True)
if not videoId:
videoId = nav(result, NAVIGATION_VIDEO_ID_2)
return {
'title': nav(result, TITLE_TEXT),
'videoId': nav(result, NAVIGATION_VIDEO_ID),
'videoId': videoId,
'artists': parse_song_artists_runs(runs[:artists_len]),
'playlistId': nav(result, NAVIGATION_PLAYLIST_ID, True),
'thumbnails': nav(result, THUMBNAIL_RENDERER, True),
Expand Down

0 comments on commit f1141d3

Please sign in to comment.