diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2013-12-09 18:29:07 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2013-12-09 18:29:07 +0100 |
commit | 1c088fa89ddf1e7065334e9063c378d90c668cdb (patch) | |
tree | 1e4d8352d19e763c4bac520bfe42c09a6c9b0638 /youtube_dl/utils.py | |
parent | 395293a88956a030f1be637748d50d216ff317a5 (diff) |
Improve --bidi-workaround support
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 5ba06d965..64300d8e0 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -15,6 +15,7 @@ import platform import re import ssl import socket +import subprocess import sys import traceback import zlib @@ -1024,6 +1025,23 @@ def format_bytes(bytes): converted = float(bytes) / float(1024 ** exponent) return u'%.2f%s' % (converted, suffix) + def str_to_int(int_str): int_str = re.sub(r'[,\.]', u'', int_str) return int(int_str) + + +def get_term_width(): + columns = os.environ.get('COLUMNS', None) + if columns: + return int(columns) + + try: + sp = subprocess.Popen( + ['stty', 'size'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = sp.communicate() + return int(out.split()[1]) + except: + pass + return None |