From 7de7ecfcc0bfae0df6aeb9d997a0eebeb917d853 Mon Sep 17 00:00:00 2001 From: atlasrule <51425254+atlasrule@users.noreply.github.com> Date: Fri, 23 Sep 2022 08:04:45 +0300 Subject: [PATCH] Add check if absent Checking if nested objects absent solved solved my issue, #298 I'm not sure if it's suitable. --- ytmusicapi/parsers/playlists.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ytmusicapi/parsers/playlists.py b/ytmusicapi/parsers/playlists.py index c538e63..21b4012 100644 --- a/ytmusicapi/parsers/playlists.py +++ b/ytmusicapi/parsers/playlists.py @@ -32,12 +32,13 @@ def parse_playlist_items(results, menu_entries: List[List] = None): feedback_tokens = parse_song_menu_tokens(item) # if item is not playable, the videoId was retrieved above - if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON): - videoId = nav(data, - PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId'] + if nav(data, PLAY_BUTTON, none_if_absent=True) != None: + if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON): + videoId = nav(data, + PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId'] - if 'menu' in data: - like = nav(data, MENU_LIKE_STATUS, True) + if 'menu' in data: + like = nav(data, MENU_LIKE_STATUS, True) title = get_item_text(data, 0) if title == 'Song deleted':