[GH-ISSUE #606] get_playlist does not work for all languages #416

Closed
opened 2026-02-27 23:00:40 +03:00 by kerem · 1 comment
Owner

Originally created by @JohnHKoh on GitHub (Jun 21, 2024).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/606

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:

  1. Set YTMusic language parameter to Korean (language="ko")
  2. Run ytmusic.get_playlist(playlistId)
  3. See error

Additional context
github.com/sigma67/ytmusicapi@11823d6387/ytmusicapi/mixins/playlists.py (L214-L215)
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.

Originally created by @JohnHKoh on GitHub (Jun 21, 2024). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/606 **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: 1. Set `YTMusic` language parameter to Korean (`language="ko"`) 2. Run `ytmusic.get_playlist(playlistId)` 3. See error **Additional context** https://github.com/sigma67/ytmusicapi/blob/11823d638719d76456ec58a6d7b76133368e5f1a/ytmusicapi/mixins/playlists.py#L214-L215 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.
kerem closed this issue 2026-02-27 23:00:41 +03:00
Author
Owner

@JohnHKoh commented on GitHub (Jun 21, 2024):

Closing as duplicate.

<!-- gh-comment-id:2183185824 --> @JohnHKoh commented on GitHub (Jun 21, 2024): Closing as duplicate.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#416
No description provided.