sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.76k stars 209 forks source link

Incorrect track count for playlists with 1000+ songs #650

Closed RealCalumPlays closed 1 month ago

RealCalumPlays commented 2 months ago

Hello all,

This is an issue with the regex in the playlist mixin. It causes only the first group to be returned. For example if the playlist had 3647 songs it would return 3 due to how re.search(r"\d+", song_count_text) is used.

To Reproduce Steps to reproduce the behavior:

  1. Find a playlist with 1000+ songs
  2. Use the YTMusic.get_playlist() function
  3. Print the trackCount object.
  4. It should return only the first digit

Additional context

from ytmusicapi import YTMusic

# Initialize YouTube Music API
ytmusic = YTMusic()

PLAYLIST_ID = "XXXXXX"

# Call get_playlist
playlist = ytmusic.get_playlist(PLAYLIST_ID)

#Print trackCount to the console
print(playlist["trackCount"])