from youtube_dl.utils import unescapeHTML
from youtube_dl.utils import orderedSet
-if sys.version < (3,0):
+if sys.version_info < (3,0):
_compat_str = lambda b: b.decode('unicode-escape')
else:
_compat_str = lambda s: s
# Forced printings
if self.params.get('forcetitle', False):
- print(info_dict['title'].encode(preferredencoding(), 'xmlcharrefreplace'))
+ compat_print(info_dict['title'].encode(preferredencoding(), 'xmlcharrefreplace'))
if self.params.get('forceurl', False):
- print(info_dict['url'].encode(preferredencoding(), 'xmlcharrefreplace'))
+ compat_print(info_dict['url'].encode(preferredencoding(), 'xmlcharrefreplace'))
if self.params.get('forcethumbnail', False) and 'thumbnail' in info_dict:
- print(info_dict['thumbnail'].encode(preferredencoding(), 'xmlcharrefreplace'))
+ compat_print(info_dict['thumbnail'].encode(preferredencoding(), 'xmlcharrefreplace'))
if self.params.get('forcedescription', False) and 'description' in info_dict:
- print(info_dict['description'].encode(preferredencoding(), 'xmlcharrefreplace'))
+ compat_print(info_dict['description'].encode(preferredencoding(), 'xmlcharrefreplace'))
if self.params.get('forcefilename', False) and filename is not None:
- print(filename.encode(preferredencoding(), 'xmlcharrefreplace'))
+ compat_print(filename.encode(preferredencoding(), 'xmlcharrefreplace'))
if self.params.get('forceformat', False):
- print(info_dict['format'].encode(preferredencoding(), 'xmlcharrefreplace'))
+ compat_print(info_dict['format'].encode(preferredencoding(), 'xmlcharrefreplace'))
# Do nothing else if in simulate mode
if self.params.get('simulate', False):
return
if 'token' not in video_info:
if 'reason' in video_info:
- self._downloader.trouble(u'ERROR: YouTube said: %s' % video_info['reason'][0].decode('utf-8'))
+ self._downloader.trouble(u'ERROR: YouTube said: %s' % video_info['reason'][0])
else:
self._downloader.trouble(u'ERROR: "token" parameter not in video info for unknown reason')
return
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',
return pref
+if sys.version_info < (3,0):
+ def compat_print(s):
+ print(s.encode(preferredencoding(), 'xmlcharrefreplace'))
+else:
+ def compat_print(s):
+ print(s)
def htmlentity_transform(matchobj):
"""Transforms an HTML entity to a character.