Skip to content

Commit

Permalink
Fix KeyError when playlist is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
bretsky authored and sigma67 committed Nov 24, 2022
1 parent d48951f commit 2344a17
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ytmusicapi/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def to_int(string):


def sum_total_duration(item):
if 'tracks' not in item:
return 0
return sum([
track['duration_seconds'] if 'duration_seconds' in track else 0 for track in item['tracks']
])

0 comments on commit 2344a17

Please sign in to comment.