Browse Source

Work around a Python bug on Windows with UTF-8 configuration (#820)

Philipp Hagemeister 12 years ago
parent
commit
0d94f2474c
1 changed files with 6 additions and 0 deletions
  1. 6 0
      youtube_dl/__init__.py

+ 6 - 0
youtube_dl/__init__.py

@@ -30,6 +30,7 @@ __authors__  = (
 
 __license__ = 'Public Domain'
 
+import codecs
 import getpass
 import optparse
 import os
@@ -335,6 +336,11 @@ def parseOpts(overrideArguments=None):
     return parser, opts, args
 
 def _real_main(argv=None):
+    # Compatibility fixes for Windows
+    if sys.platform == 'win32':
+        # https://github.com/rg3/youtube-dl/issues/820
+        codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp65001' else None)
+
     parser, opts, args = parseOpts(argv)
 
     # Open appropriate CookieJar