Skip to content

Commit

Permalink
Make song result dependent on the song having an album (some songs ha…
Browse files Browse the repository at this point in the history
…ve no album)
  • Loading branch information
sigma67 committed Feb 23, 2020
1 parent fcea964 commit 1ac614e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ytmusicapi/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 1ac614e

Please sign in to comment.