From ffc0eba3f5cdadaeba40a170995e649e5152b800 Mon Sep 17 00:00:00 2001 From: John Koh Date: Fri, 21 Jun 2024 13:44:26 -0400 Subject: [PATCH] Add fix in parsers --- ytmusicapi/parsers/playlists.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ytmusicapi/parsers/playlists.py b/ytmusicapi/parsers/playlists.py index 699a73b..6a0b70b 100644 --- a/ytmusicapi/parsers/playlists.py +++ b/ytmusicapi/parsers/playlists.py @@ -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