Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Trick for youtube-dl with UnicodeEncodeError

I got this message with youtube-dl, which is a python problem.

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 5-9: ordinal not in range(256)

After a small amount of Internet searches I found clues to a solution. I really just wanted the file on the local filesystem, and I can worry about renaming it later.

LANG=latin-1 PYTHONIOENCODING=latin-1 youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=1234567890

Oh, sure the rendered file has a untypeable name, but bash autocompletion somehow still works.

mv A\ New\ Way\ Of\ Thinking \([tab]newfile.mp3

Comments