mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
[common] maybe_print() ignores any non-printable characters (which used to cause an exception, which is not intuitive)
This commit is contained in:
parent
1a8f332712
commit
cd5cfc775f
@ -126,6 +126,10 @@ if sys.stdout.isatty():
|
|||||||
else:
|
else:
|
||||||
default_encoding = locale.getpreferredencoding().lower()
|
default_encoding = locale.getpreferredencoding().lower()
|
||||||
|
|
||||||
|
def maybe_print(s):
|
||||||
|
try: print(s)
|
||||||
|
except: pass
|
||||||
|
|
||||||
def tr(s):
|
def tr(s):
|
||||||
if default_encoding == 'utf-8':
|
if default_encoding == 'utf-8':
|
||||||
return s
|
return s
|
||||||
@ -953,8 +957,8 @@ def print_info(site_info, title, type, size):
|
|||||||
else:
|
else:
|
||||||
type_info = "Unknown type (%s)" % type
|
type_info = "Unknown type (%s)" % type
|
||||||
|
|
||||||
print("Site: ", site_info)
|
maybe_print("Site: ", site_info)
|
||||||
print("Title: ", unescape_html(tr(title)))
|
maybe_print("Title: ", unescape_html(tr(title)))
|
||||||
print("Type: ", type_info)
|
print("Type: ", type_info)
|
||||||
print("Size: ", round(size / 1048576, 2), "MiB (" + str(size) + " Bytes)")
|
print("Size: ", round(size / 1048576, 2), "MiB (" + str(size) + " Bytes)")
|
||||||
print()
|
print()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from .common import match1, download_urls, get_filename, parse_host, set_proxy, unset_proxy
|
from .common import match1, maybe_print, download_urls, get_filename, parse_host, set_proxy, unset_proxy
|
||||||
from .util import log
|
from .util import log
|
||||||
from . import json_output
|
from . import json_output
|
||||||
import os
|
import os
|
||||||
@ -111,14 +111,14 @@ class VideoExtractor():
|
|||||||
else:
|
else:
|
||||||
stream = self.dash_streams[stream_id]
|
stream = self.dash_streams[stream_id]
|
||||||
|
|
||||||
print(" - title: %s" % self.title)
|
maybe_print(" - title: %s" % self.title)
|
||||||
print(" size: %s MiB (%s bytes)" % (round(stream['size'] / 1048576, 1), stream['size']))
|
print(" size: %s MiB (%s bytes)" % (round(stream['size'] / 1048576, 1), stream['size']))
|
||||||
print(" url: %s" % self.url)
|
print(" url: %s" % self.url)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def p(self, stream_id=None):
|
def p(self, stream_id=None):
|
||||||
print("site: %s" % self.__class__.name)
|
maybe_print("site: %s" % self.__class__.name)
|
||||||
print("title: %s" % self.title)
|
maybe_print("title: %s" % self.title)
|
||||||
if stream_id:
|
if stream_id:
|
||||||
# Print the stream
|
# Print the stream
|
||||||
print("stream:")
|
print("stream:")
|
||||||
@ -151,7 +151,7 @@ class VideoExtractor():
|
|||||||
print(" download-url: {}\n".format(i['url']))
|
print(" download-url: {}\n".format(i['url']))
|
||||||
|
|
||||||
def p_playlist(self, stream_id=None):
|
def p_playlist(self, stream_id=None):
|
||||||
print("site: %s" % self.__class__.name)
|
maybe_print("site: %s" % self.__class__.name)
|
||||||
print("playlist: %s" % self.title)
|
print("playlist: %s" % self.title)
|
||||||
print("videos:")
|
print("videos:")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user