aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPhilipp Hagemeister <[email protected]>2013-11-25 22:31:27 +0100
committerPhilipp Hagemeister <[email protected]>2013-11-25 22:31:38 +0100
commitd9b011f201ef61c10ce63b6078cd1e21b6da4d4a (patch)
treea94b6e04f3262e77a31a3222e7600e0ad8a46c63
parentb0b9eaa19616da56c1d6a3ac152b31ade5ac1189 (diff)
downloadyoutube-dl-d9b011f201ef61c10ce63b6078cd1e21b6da4d4a.tar.gz
youtube-dl-d9b011f201ef61c10ce63b6078cd1e21b6da4d4a.zip
Fix rtmpdump with non-ASCII filenames on Windows on 2.x
Reported in #1798
-rw-r--r--youtube_dl/FileDownloader.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py
index 27684d0f6..3ff9716b3 100644
--- a/youtube_dl/FileDownloader.py
+++ b/youtube_dl/FileDownloader.py
@@ -339,13 +339,29 @@ class FileDownloader(object):
if live:
basic_args += ['--live']
args = basic_args + [[], ['--resume', '--skip', '1']][self.params.get('continuedl', False)]
+
+ if sys.platform == 'win32' and sys.version_info < (3, 0):
+ # Windows subprocess module does not actually support Unicode
+ # on Python 2.x
+ # See http://stackoverflow.com/a/9951851/35070
+ subprocess_encoding = sys.getfilesystemencoding()
+ args = [a.encode(subprocess_encoding, 'ignore') for a in args]
+ else:
+ subprocess_encoding = None
+
if self.params.get('verbose', False):
+ if subprocess_encoding:
+ str_args = [
+ a.decode(subprocess_encoding) if isinstance(a, bytes) else a
+ for a in args]
+ else:
+ str_args = args
try:
import pipes
- shell_quote = lambda args: ' '.join(map(pipes.quote, args))
+ shell_quote = lambda args: ' '.join(map(pipes.quote, str_args))
except ImportError:
shell_quote = repr
- self.to_screen(u'[debug] rtmpdump command line: ' + shell_quote(args))
+ self.to_screen(u'[debug] rtmpdump command line: ' + shell_quote(str_args))
retval = run_rtmpdump(args)