diff --git a/spotdl/download/downloader.py b/spotdl/download/downloader.py index 9a8488cd9..7aff91375 100644 --- a/spotdl/download/downloader.py +++ b/spotdl/download/downloader.py @@ -545,7 +545,15 @@ def search_and_download(self, song: Song) -> Tuple[Song, Optional[Path]]: ) return song, output_file - except Exception as exception: + except (Exception, UnicodeEncodeError) as exception: + if isinstance(exception, UnicodeEncodeError): + exception_cause = exception + exception = DownloaderError( + "You may need to add PYTHONIOENCODING=utf-8 to your environment" + ) + + exception.__cause__ = exception_cause + display_progress_tracker.notify_error( traceback.format_exc(), exception, True ) diff --git a/spotdl/download/progress_handler.py b/spotdl/download/progress_handler.py index 0cdd71a5a..570bbf7be 100644 --- a/spotdl/download/progress_handler.py +++ b/spotdl/download/progress_handler.py @@ -388,6 +388,14 @@ def __init__(self, parent, song: Song) -> None: self.parent: "ProgressHandler" = parent self.song = song + # Clean up the song name + # from weird unicode characters + self.song_name = "".join( + char + for char in self.song.name + if char not in [chr(i) for i in range(769, 880)] + ) + self.progress: int = 0 self.old_progress: int = 0 self.status = ""