aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-12-23 04:19:20 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2013-12-23 04:19:50 +0100
commit5d681e960db98ec2d9f3d4361bd66f581506a772 (patch)
tree5a9b3a56a4ff4dc001821ea8e3e0bd6c9bf6f9b8
parentc7b487d96b1307508843321d17949356e03ace6a (diff)
downloadyoutube-dl-5d681e960db98ec2d9f3d4361bd66f581506a772.tar.xz
Use bidiv instead of fribidi if available (Fixes #1912)
-rw-r--r--youtube_dl/YoutubeDL.py23
-rw-r--r--youtube_dl/__init__.py2
2 files changed, 17 insertions, 8 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 2a078adfb..e19708e0d 100644
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -183,12 +183,19 @@ class YoutubeDL(object):
width_args = []
else:
width_args = ['-w', str(width)]
- self._fribidi = subprocess.Popen(
- ['fribidi', '-c', 'UTF-8'] + width_args,
+ sp_kwargs = dict(
stdin=subprocess.PIPE,
stdout=slave,
stderr=self._err_file)
- self._fribidi_channel = os.fdopen(master, 'rb')
+ try:
+ self._output_process = subprocess.Popen(
+ ['bidiv'] + width_args, **sp_kwargs
+ )
+ except OSError:
+ print('Falling back to fribidi')
+ self._output_process = subprocess.Popen(
+ ['fribidi', '-c', 'UTF-8'] + width_args, **sp_kwargs)
+ self._output_channel = os.fdopen(master, 'rb')
except OSError as ose:
if ose.errno == 2:
self.report_warning(u'Could not find fribidi executable, ignoring --bidi-workaround . Make sure that fribidi is an executable file in one of the directories in your $PATH.')
@@ -243,14 +250,16 @@ class YoutubeDL(object):
pp.set_downloader(self)
def _bidi_workaround(self, message):
- if not hasattr(self, '_fribidi_channel'):
+ if not hasattr(self, '_output_channel'):
+ print('WORKAROUND NOT ENABLED')
return message
+ assert hasattr(self, '_output_process')
assert type(message) == type(u'')
line_count = message.count(u'\n') + 1
- self._fribidi.stdin.write((message + u'\n').encode('utf-8'))
- self._fribidi.stdin.flush()
- res = u''.join(self._fribidi_channel.readline().decode('utf-8')
+ self._output_process.stdin.write((message + u'\n').encode('utf-8'))
+ self._output_process.stdin.flush()
+ res = u''.join(self._output_channel.readline().decode('utf-8')
for _ in range(line_count))
return res[:-len(u'\n')]
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 63437301b..c37d28c59 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -194,7 +194,7 @@ def parseOpts(overrideArguments=None):
type=float, default=None, help=optparse.SUPPRESS_HELP)
general.add_option(
'--bidi-workaround', dest='bidi_workaround', action='store_true',
- help=u'Work around terminals that lack bidirectional text support. Requires fribidi executable in PATH')
+ help=u'Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH')
selection.add_option(