Woooohooo! python3 youtube_dl BaW_jenozKc -t works!
[youtube-dl] / youtube_dl / utils.py
index 3fcb0927faa7436419d30bfc407b76cd2c44bd4b..a5df62bf81ce0336ff4d641f8bcc93a1c27ff1c8 100644 (file)
@@ -61,7 +61,6 @@ try:
 except NameError:
        compat_chr = chr
 
-
 std_headers = {
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
@@ -83,6 +82,13 @@ def preferredencoding():
 
        return pref
 
+if sys.version_info < (3,0):
+       def compat_print(s):
+               print(s.encode(preferredencoding(), 'xmlcharrefreplace'))
+else:
+       def compat_print(s):
+               assert type(s) == type(u'')
+               print(s)
 
 def htmlentity_transform(matchobj):
        """Transforms an HTML entity to a character.
@@ -286,6 +292,10 @@ def encodeFilename(s):
 
        assert type(s) == type(u'')
 
+       # Python 3 has a Unicode API
+       if sys.version_info >= (3, 0):
+               return s
+
        if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
                # Pass u'' directly to use Unicode APIs on Windows 2000 and up
                # (Detecting Windows NT 4 is tricky because 'major >= 4' would