From 1ac614e27b7378d95e1dab0931e5449e98386608 Mon Sep 17 00:00:00 2001 From: sigma67 Date: Sun, 23 Feb 2020 19:30:39 +0100 Subject: [PATCH] Make song result dependent on the song having an album (some songs have no album) --- ytmusicapi/helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ytmusicapi/helpers.py b/ytmusicapi/helpers.py index 73dfc11..1b51d55 100644 --- a/ytmusicapi/helpers.py +++ b/ytmusicapi/helpers.py @@ -61,8 +61,10 @@ def parse_search_result(data, resultType = None): search_result['itemCount'] = get_item_text(data, 2 + default).split(' ')[0] elif resultType in ['song']: - search_result['album'] = get_item_text(data, 2 + default) - search_result['duration'] = get_item_text(data, 3 + default) + hasAlbum = len(data['flexColumns'] == 4) + if hasAlbum: + search_result['album'] = get_item_text(data, 2 + default) + search_result['duration'] = get_item_text(data, 2 + hasAlbum + default) elif resultType in ['video']: search_result['views'] = get_item_text(data, 2 + default).split(' ')[0]