scdl-org / scdl

Soundcloud Music Downloader
GNU General Public License v2.0
3.28k stars 329 forks source link

UnicodeEncodeError Locale Issues with UNIX #257

Open ghost opened 6 years ago

ghost commented 6 years ago

This isn't a scdl or Python issue, but about adding support for UNIXs without UTF-8 as the default locale.

OpenBSD has a custom UTF-8 OS locale that doesn't work well with Python3. Running

import sys
sys.getfilesystemencoding()

Yields:

'ascii'

I'm not well-versed in Python, but it should be as simple as checking for filesystemencoding (OS encoding) and if it's not UTF-8, strip it down (or ask for manual renaming) for every request -- or even just default to the url scheme.

To reproduce/test this, set LC_CTYPE=ascii as an environment variable and download a track with unicode characters. I.e

LC_CTYPE=ascii scdl -l https://soundcloud.com/deadrazy/pereverni-indeedeu

Exactly like #245

ghost commented 6 years ago

Easy work-around:

export LC_CTYPE=en_US.UTF-8

Nothing really to do on the maintainer's end, it's a system issue.

flyingrub commented 6 years ago

The problem with this fix is that windows doesn't send the right encoding...