aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-11-21 14:09:28 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-11-21 14:09:28 +0100
commita6a173c2fddf2fa38a69ca750431b7ca6932bcb0 (patch)
tree7d0aa6b243422b9d1400e8d07416aa51cb1abe0a /youtube_dl
parent2bb683c2012ad45b0e3008664be5994aa603c196 (diff)
utils.shell_quote: Convert the args to unicode strings
The youtube test video failed with `UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 34: ordinal not in range(128)`, the problem was with the filenames being encoded.
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/utils.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index b50c8166f..0720fe9eb 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -951,7 +951,16 @@ class locked_file(object):
def shell_quote(args):
- return ' '.join(map(pipes.quote, args))
+ quoted_args = []
+ encoding = sys.getfilesystemencoding()
+ if encoding is None:
+ encoding = 'utf-8'
+ for a in args:
+ if isinstance(a, bytes):
+ # We may get a filename encoded with 'encodeFilename'
+ a = a.decode(encoding)
+ quoted_args.append(pipes.quote(a))
+ return u' '.join(quoted_args)
def takewhile_inclusive(pred, seq):