mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 10:31:29 +00:00
Fix printing title etc.
This commit is contained in:
parent
64a57846d3
commit
8cd10ac4ef
|
@ -13,7 +13,7 @@
|
|||
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
|
||||
|
|
|
@ -380,17 +380,17 @@ def process_info(self, info_dict):
|
|||
|
||||
# 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):
|
||||
|
|
|
@ -339,7 +339,7 @@ def _real_extract(self, url):
|
|||
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
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
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,12 @@ def preferredencoding():
|
|||
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue