Skip to content

Commit

Permalink
remove weird characters from song name
Browse files Browse the repository at this point in the history
Update downloader.py

Update progress_handler.py
  • Loading branch information
xnetcat committed Dec 7, 2022
1 parent 6280c5e commit aacde50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spotdl/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
8 changes: 8 additions & 0 deletions spotdl/download/progress_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit aacde50

Please sign in to comment.