linsomniac / spotify_to_ytmusic

Copy playlists and liked music from Spotify to YTMusic
Creative Commons Zero v1.0 Universal
2.11k stars 132 forks source link

Program seems to break on non-English characters #63

Open reallemon opened 6 months ago

reallemon commented 6 months ago

When I run s2yt_load_liked, I am getting the following error:

UnicodeEncodeError: 'charmap' codec can't encode characters in position 11-17: character maps to <undefined>

ERROR: Unable to look up song on YTMusic: 'charmap' codec can't encode character '\u96eb' in position 69841: character maps to <undefined>

The song it is failing on: https://open.spotify.com/track/5nyZKSIW7HZSKmf13yEwS0?si=4b1ec1df31f34a62

This is with the CLI version. I don't believe I was running into the same issue with the GUI, but it's hard to tell when the output is so full of JSON that I can't really tell what is happening.

linsomniac commented 6 months ago

Can I get the full traceback please?

reallemon commented 6 months ago
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python311\Scripts\s2yt_load_liked.exe\__main__.py", line 7, in <module>
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotify2ytmusic\cli.py", line 199, in load_liked
    backend.copier(
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotify2ytmusic\backend.py", line 380, in copier
    print(f"Spotify:   {src_track.title} - {src_track.artist} - {src_track.album}")
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 11-17: character maps to <undefined>
calebrichter commented 5 months ago

I was running into a ton of issues with encoding with the attached playlists.json

At points in the program the default encoding was being changing to using cp1252.py

I was able to resolve all my issues by running:

python -X utf8 -m spotify2ytmusic load_liked

Forcing python to read all the strings in utf-8

playlists.json playlists.json