Compare commits
5 Commits
2013.12.23
...
2013.12.23
Author | SHA1 | Date | |
---|---|---|---|
![]() |
504c668d3b | ||
![]() |
466617f539 | ||
![]() |
196938835a | ||
![]() |
a94e129a65 | ||
![]() |
5d681e960d |
@@ -39,7 +39,8 @@ which means you can modify it, redistribute it or use it however you like.
|
|||||||
/youtube-dl .
|
/youtube-dl .
|
||||||
--no-cache-dir Disable filesystem caching
|
--no-cache-dir Disable filesystem caching
|
||||||
--bidi-workaround Work around terminals that lack bidirectional
|
--bidi-workaround Work around terminals that lack bidirectional
|
||||||
text support. Requires fribidi executable in PATH
|
text support. Requires bidiv or fribidi
|
||||||
|
executable in PATH
|
||||||
|
|
||||||
## Video Selection:
|
## Video Selection:
|
||||||
--playlist-start NUMBER playlist video to start at (default is 1)
|
--playlist-start NUMBER playlist video to start at (default is 1)
|
||||||
|
@@ -183,12 +183,18 @@ class YoutubeDL(object):
|
|||||||
width_args = []
|
width_args = []
|
||||||
else:
|
else:
|
||||||
width_args = ['-w', str(width)]
|
width_args = ['-w', str(width)]
|
||||||
self._fribidi = subprocess.Popen(
|
sp_kwargs = dict(
|
||||||
['fribidi', '-c', 'UTF-8'] + width_args,
|
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=slave,
|
stdout=slave,
|
||||||
stderr=self._err_file)
|
stderr=self._err_file)
|
||||||
self._fribidi_channel = os.fdopen(master, 'rb')
|
try:
|
||||||
|
self._output_process = subprocess.Popen(
|
||||||
|
['bidiv'] + width_args, **sp_kwargs
|
||||||
|
)
|
||||||
|
except OSError:
|
||||||
|
self._output_process = subprocess.Popen(
|
||||||
|
['fribidi', '-c', 'UTF-8'] + width_args, **sp_kwargs)
|
||||||
|
self._output_channel = os.fdopen(master, 'rb')
|
||||||
except OSError as ose:
|
except OSError as ose:
|
||||||
if ose.errno == 2:
|
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.')
|
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 +249,15 @@ class YoutubeDL(object):
|
|||||||
pp.set_downloader(self)
|
pp.set_downloader(self)
|
||||||
|
|
||||||
def _bidi_workaround(self, message):
|
def _bidi_workaround(self, message):
|
||||||
if not hasattr(self, '_fribidi_channel'):
|
if not hasattr(self, '_output_channel'):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
assert hasattr(self, '_output_process')
|
||||||
assert type(message) == type(u'')
|
assert type(message) == type(u'')
|
||||||
line_count = message.count(u'\n') + 1
|
line_count = message.count(u'\n') + 1
|
||||||
self._fribidi.stdin.write((message + u'\n').encode('utf-8'))
|
self._output_process.stdin.write((message + u'\n').encode('utf-8'))
|
||||||
self._fribidi.stdin.flush()
|
self._output_process.stdin.flush()
|
||||||
res = u''.join(self._fribidi_channel.readline().decode('utf-8')
|
res = u''.join(self._output_channel.readline().decode('utf-8')
|
||||||
for _ in range(line_count))
|
for _ in range(line_count))
|
||||||
return res[:-len(u'\n')]
|
return res[:-len(u'\n')]
|
||||||
|
|
||||||
|
@@ -194,7 +194,7 @@ def parseOpts(overrideArguments=None):
|
|||||||
type=float, default=None, help=optparse.SUPPRESS_HELP)
|
type=float, default=None, help=optparse.SUPPRESS_HELP)
|
||||||
general.add_option(
|
general.add_option(
|
||||||
'--bidi-workaround', dest='bidi_workaround', action='store_true',
|
'--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(
|
selection.add_option(
|
||||||
|
@@ -70,13 +70,14 @@ class BlipTVIE(InfoExtractor):
|
|||||||
info = None
|
info = None
|
||||||
urlh = self._request_webpage(request, None, False,
|
urlh = self._request_webpage(request, None, False,
|
||||||
u'unable to download video info webpage')
|
u'unable to download video info webpage')
|
||||||
|
|
||||||
if urlh.headers.get('Content-Type', '').startswith('video/'): # Direct download
|
if urlh.headers.get('Content-Type', '').startswith('video/'): # Direct download
|
||||||
basename = url.split('/')[-1]
|
basename = url.split('/')[-1]
|
||||||
title,ext = os.path.splitext(basename)
|
title,ext = os.path.splitext(basename)
|
||||||
title = title.decode('UTF-8')
|
title = title.decode('UTF-8')
|
||||||
ext = ext.replace('.', '')
|
ext = ext.replace('.', '')
|
||||||
self.report_direct_download(title)
|
self.report_direct_download(title)
|
||||||
info = {
|
return {
|
||||||
'id': title,
|
'id': title,
|
||||||
'url': url,
|
'url': url,
|
||||||
'uploader': None,
|
'uploader': None,
|
||||||
@@ -85,49 +86,47 @@ class BlipTVIE(InfoExtractor):
|
|||||||
'ext': ext,
|
'ext': ext,
|
||||||
'urlhandle': urlh
|
'urlhandle': urlh
|
||||||
}
|
}
|
||||||
if info is None: # Regular URL
|
|
||||||
try:
|
|
||||||
json_code_bytes = urlh.read()
|
|
||||||
json_code = json_code_bytes.decode('utf-8')
|
|
||||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
|
||||||
raise ExtractorError(u'Unable to read video info webpage: %s' % compat_str(err))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
json_data = json.loads(json_code)
|
json_code_bytes = urlh.read()
|
||||||
if 'Post' in json_data:
|
json_code = json_code_bytes.decode('utf-8')
|
||||||
data = json_data['Post']
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
else:
|
raise ExtractorError(u'Unable to read video info webpage: %s' % compat_str(err))
|
||||||
data = json_data
|
|
||||||
|
|
||||||
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
try:
|
||||||
if 'additionalMedia' in data:
|
json_data = json.loads(json_code)
|
||||||
formats = sorted(data['additionalMedia'], key=lambda f: int(f['media_height']))
|
if 'Post' in json_data:
|
||||||
best_format = formats[-1]
|
data = json_data['Post']
|
||||||
video_url = best_format['url']
|
else:
|
||||||
else:
|
data = json_data
|
||||||
video_url = data['media']['url']
|
|
||||||
umobj = re.match(self._URL_EXT, video_url)
|
|
||||||
if umobj is None:
|
|
||||||
raise ValueError('Can not determine filename extension')
|
|
||||||
ext = umobj.group(1)
|
|
||||||
|
|
||||||
info = {
|
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
||||||
'id': compat_str(data['item_id']),
|
if 'additionalMedia' in data:
|
||||||
'url': video_url,
|
formats = sorted(data['additionalMedia'], key=lambda f: int(f['media_height']))
|
||||||
'uploader': data['display_name'],
|
best_format = formats[-1]
|
||||||
'upload_date': upload_date,
|
video_url = best_format['url']
|
||||||
'title': data['title'],
|
else:
|
||||||
'ext': ext,
|
video_url = data['media']['url']
|
||||||
'format': data['media']['mimeType'],
|
umobj = re.match(self._URL_EXT, video_url)
|
||||||
'thumbnail': data['thumbnailUrl'],
|
if umobj is None:
|
||||||
'description': data['description'],
|
raise ValueError('Can not determine filename extension')
|
||||||
'player_url': data['embedUrl'],
|
ext = umobj.group(1)
|
||||||
'user_agent': 'iTunes/10.6.1',
|
|
||||||
}
|
|
||||||
except (ValueError,KeyError) as err:
|
|
||||||
raise ExtractorError(u'Unable to parse video information: %s' % repr(err))
|
|
||||||
|
|
||||||
return [info]
|
return {
|
||||||
|
'id': compat_str(data['item_id']),
|
||||||
|
'url': video_url,
|
||||||
|
'uploader': data['display_name'],
|
||||||
|
'upload_date': upload_date,
|
||||||
|
'title': data['title'],
|
||||||
|
'ext': ext,
|
||||||
|
'format': data['media']['mimeType'],
|
||||||
|
'thumbnail': data['thumbnailUrl'],
|
||||||
|
'description': data['description'],
|
||||||
|
'player_url': data['embedUrl'],
|
||||||
|
'user_agent': 'iTunes/10.6.1',
|
||||||
|
}
|
||||||
|
except (ValueError, KeyError) as err:
|
||||||
|
raise ExtractorError(u'Unable to parse video information: %s' % repr(err))
|
||||||
|
|
||||||
|
|
||||||
class BlipTVUserIE(InfoExtractor):
|
class BlipTVUserIE(InfoExtractor):
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
|
|
||||||
__version__ = '2013.12.23'
|
__version__ = '2013.12.23.2'
|
||||||
|
Reference in New Issue
Block a user