OrfiTeam / OrpheusDL

615 stars 77 forks source link

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

Open CarterMoody opened 1 month ago

CarterMoody commented 1 month ago

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 commented 1 month ago

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

image

OrfiDev commented 1 month ago

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

CarterMoody commented 1 month ago

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