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

[BUG] Can't process certain characters or Emoji 👍 #66

Open
CarterMoody opened this issue Oct 4, 2024 · 3 comments
Open

[BUG] Can't process certain characters or Emoji 👍 #66

CarterMoody opened this issue Oct 4, 2024 · 3 comments

Comments

@CarterMoody
Copy link

When downloading a playlist that contains a song from here: https://www.deezer.com/us/album/14617442

I get this error:

Traceback (most recent call last):
File "C:\OrpheusDL\OrpheusDL\orpheus.py", line 225, in
main()
File "C:\OrpheusDL\OrpheusDL\orpheus.py", line 220, in main
orpheus_core_download(orpheus, media_to_download, tpm, sdm, path)
File "C:\OrpheusDL\OrpheusDL\orpheus\core.py", line 401, in orpheus_core_download
downloader.download_playlist(media_id, extra_kwargs=media.extra_kwargs)
File "C:\OrpheusDL\OrpheusDL\orpheus\music_downloader.py", line 154, in download_playlist
self.download_track(track_id, album_location=playlist_path, track_index=index, number_of_tracks=number_of_tracks, indent_level=2, m3u_playlist=m3u_playlist_path, extra_kwargs=playlist_info.track_extra_kwargs)
File "C:\OrpheusDL\OrpheusDL\orpheus\music_downloader.py", line 316, in download_track
self.print(f'=== Downloading track {track_info.name} ({track_id}) ===', drop_level=1)
File "C:\OrpheusDL\OrpheusDL\utils\models.py", line 32, in oprint
print(' ' * (self.indent_number - drop_level * self.multiplier) + inp)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\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 32-38: character maps to

OR When attempting to download a playlist with emoji in its title

python3 orpheus.py https://www.deezer.com/us/playlist/12215288251

Traceback (most recent call last):
File "C:\OrpheusDL\OrpheusDL\orpheus.py", line 225, in
main()
File "C:\OrpheusDL\OrpheusDL\orpheus.py", line 220, in main
orpheus_core_download(orpheus, media_to_download, tpm, sdm, path)
File "C:\OrpheusDL\OrpheusDL\orpheus\core.py", line 401, in orpheus_core_download
downloader.download_playlist(media_id, extra_kwargs=media.extra_kwargs)
File "C:\OrpheusDL\OrpheusDL\orpheus\music_downloader.py", line 71, in download_playlist
self.print(f'=== Downloading playlist {playlist_info.name} ({playlist_id}) ===', drop_level=1)
File "C:\OrpheusDL\OrpheusDL\utils\models.py", line 32, in oprint
print(' ' * (self.indent_number - drop_level * self.multiplier) + inp)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f60a' in position 30: character maps to

@CarterMoody
Copy link
Author

CarterMoody commented Oct 4, 2024

The fix seems to be a simple try/except around this print in utils/models.py

image

@OrfiDev
Copy link
Member

OrfiDev commented Oct 4, 2024

I'm surprised this bug never showed up before, also try/except isn't really a good solution for this.

@CarterMoody
Copy link
Author

Thanks. Yes I agree there are better methods for handling this but I wanted the quick/dirty

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

2 participants