Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_playlist does not work for all languages #608

Open
JohnHKoh opened this issue Jun 21, 2024 · 0 comments
Open

get_playlist does not work for all languages #608

JohnHKoh opened this issue Jun 21, 2024 · 0 comments

Comments

@JohnHKoh
Copy link
Contributor

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

song_count = second_subtitle_runs[has_views + 0]["text"].split(" ")
song_count = to_int(song_count[0]) if len(song_count) > 1 else 0

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant