`get_playlist` does not work for all languages
JohnHKoh opened this issue · 1 comments
JohnHKoh commented
Describe the bug
I receive the following errors when trying to run get_playlist
with the Korean ("ko
") language using v1.7.3:
Traceback (most recent call last):
File "C:\Users\asdf\AppData\Local\Programs\Python\Python311\Lib\site-packages\ytmusicapi\helpers.py", line 64, in to_int
int_value = locale.atoi(number_string)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\asdf\AppData\Local\Programs\Python\Python311\Lib\locale.py", line 342, in atoi
return int(delocalize(string))
^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
and
File "C:\Users\asdf\Source\MelonYTMPlaylist\src\playlist_updater.py", line 117, in get_playlist
return self.ytmusic.get_playlist(self.playlistId, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\asdf\AppData\Local\Programs\Python\Python311\Lib\site-packages\ytmusicapi\mixins\playlists.py", line 111, in get_playlist
return self._parse_new_playlist_format(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\asdf\AppData\Local\Programs\Python\Python311\Lib\site-packages\ytmusicapi\mixins\playlists.py", line 215, in _parse_new_playlist_format
song_count = to_int(song_count[0]) if len(song_count) > 1 else 0
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\asdf\AppData\Local\Programs\Python\Python311\Lib\site-packages\ytmusicapi\helpers.py", line 67, in to_int
int_value = int(number_string)
^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
To Reproduce
Steps to reproduce the behavior:
- Set
YTMusic
language parameter to Korean (language="ko"
) - Run
ytmusic.get_playlist(playlistId)
- See error
Additional context
ytmusicapi/ytmusicapi/mixins/playlists.py
Lines 214 to 215 in 11823d6
These seem to be the offending lines. While English returns "100 tracks" for
second_subtitle_runs[has_views + 0]["text"]
, in Korean, it returns "트랙 100개", Therefore, song_count[0]
does not have the correct value in the Korean language. The integer should be extracted from the string to account for such differences.JohnHKoh commented
Closing as duplicate.