Skip to content

Commit

Permalink
fix sum_total_duration failing if duration_seconds is not an int (#598)
Browse files Browse the repository at this point in the history
* fix sum_total_duration failing if duration_seconds is not an int

Signed-off-by: Adwait Thattey <coderdude1999@gmail.com>

* format

---------

Signed-off-by: Adwait Thattey <coderdude1999@gmail.com>
Co-authored-by: sigma67 <sigma67.github@gmail.com>
  • Loading branch information
adwait-thattey and sigma67 committed Jul 3, 2024
1 parent d2cbe53 commit ab2aa28
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ytmusicapi/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,11 @@ 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"]])
return sum(
[
track["duration_seconds"]
if ("duration_seconds" in track and isinstance(track["duration_seconds"], int))
else 0
for track in item["tracks"]
]
)

0 comments on commit ab2aa28

Please sign in to comment.