Skip to content

Commit

Permalink
Add fix in parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHKoh committed Jun 21, 2024
1 parent 1d62e98 commit ffc0eba
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ytmusicapi/parsers/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ def parse_playlist_header(response: Dict) -> Dict[str, Any]:
playlist["duration"] = (
None if not has_duration else second_subtitle_runs[has_views + has_duration]["text"]
)
song_count = second_subtitle_runs[has_views + 0]["text"].split(" ")
song_count = to_int(song_count[0]) if len(song_count) > 1 else 0
song_count_text = second_subtitle_runs[has_views + 0]["text"]
song_count_search = re.search(r"\d+", song_count_text)
# extract the digits from the text, return 0 if no match
song_count = to_int(song_count_search.group()) if song_count_search is not None else 0
playlist["trackCount"] = song_count

return playlist
Expand Down

0 comments on commit ffc0eba

Please sign in to comment.