From 55965940d34aa96df27bb32475ee8047718c4544 Mon Sep 17 00:00:00 2001 From: sigma67 Date: Sun, 23 Aug 2020 14:35:28 +0200 Subject: [PATCH] Fix get_song if release/production missing (closes #57) --- ytmusicapi/mixins/browsing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ytmusicapi/mixins/browsing.py b/ytmusicapi/mixins/browsing.py index a4e8e0f..8be2899 100644 --- a/ytmusicapi/mixins/browsing.py +++ b/ytmusicapi/mixins/browsing.py @@ -528,9 +528,9 @@ class BrowsingMixin: song_meta['provider'] = description[0].replace('Provided to YouTube by ', '') song_meta['artists'] = [artist for artist in description[1].split(' ยท ')[1:]] song_meta['copyright'] = description[3] - song_meta['production'] = [pub for pub in description[5].split('\n')] - song_meta['release'] = description[4].replace('Released on: ', '') - except KeyError: + song_meta['release'] = None if len(description) < 5 else description[4].replace('Released on: ', '') + song_meta['production'] = None if len(description) < 6 else [pub for pub in description[5].split('\n')] + except (KeyError, IndexError): pass song_meta['streamingData'] = player_response['streamingData'] return song_meta