forked from minhngoc25a/yt-dlc
Merge remote-tracking branch 'rzhxeo/blip2'
This commit is contained in:
commit
67c20aebb7
|
@ -14,6 +14,7 @@ from ..utils import (
|
||||||
|
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
|
determine_ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +22,6 @@ class BlipTVIE(InfoExtractor):
|
||||||
"""Information extractor for blip.tv"""
|
"""Information extractor for blip.tv"""
|
||||||
|
|
||||||
_VALID_URL = r'^(?:https?://)?(?:www\.)?blip\.tv/((.+/)|(play/)|(api\.swf#))(.+)$'
|
_VALID_URL = r'^(?:https?://)?(?:www\.)?blip\.tv/((.+/)|(play/)|(api\.swf#))(.+)$'
|
||||||
_URL_EXT = r'^.*\.([a-z0-9]+)$'
|
|
||||||
IE_NAME = u'blip.tv'
|
IE_NAME = u'blip.tv'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://blip.tv/cbr/cbr-exclusive-gotham-city-imposters-bats-vs-jokerz-short-3-5796352',
|
u'url': u'http://blip.tv/cbr/cbr-exclusive-gotham-city-imposters-bats-vs-jokerz-short-3-5796352',
|
||||||
|
@ -82,29 +82,35 @@ class BlipTVIE(InfoExtractor):
|
||||||
data = json_data
|
data = json_data
|
||||||
|
|
||||||
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
||||||
|
formats = []
|
||||||
if 'additionalMedia' in data:
|
if 'additionalMedia' in data:
|
||||||
formats = sorted(data['additionalMedia'], key=lambda f: int(f['media_height']))
|
for f in sorted(data['additionalMedia'], key=lambda f: int(f['media_height'])):
|
||||||
best_format = formats[-1]
|
if not int(f['media_width']): # filter m3u8
|
||||||
video_url = best_format['url']
|
continue
|
||||||
|
formats.append({
|
||||||
|
'url': f['url'],
|
||||||
|
'ext': determine_ext(f['url']),
|
||||||
|
'format_id': f['role'],
|
||||||
|
'width': int(f['media_width']),
|
||||||
|
'height': int(f['media_height']),
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
video_url = data['media']['url']
|
formats.append({
|
||||||
umobj = re.match(self._URL_EXT, video_url)
|
'url': data['media']['url'],
|
||||||
if umobj is None:
|
'ext': determine_ext(data['media']['url']),
|
||||||
raise ValueError('Can not determine filename extension')
|
'width': int(data['media']['width']),
|
||||||
ext = umobj.group(1)
|
'height': int(data['media']['height']),
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': compat_str(data['item_id']),
|
'id': compat_str(data['item_id']),
|
||||||
'url': video_url,
|
|
||||||
'uploader': data['display_name'],
|
'uploader': data['display_name'],
|
||||||
'upload_date': upload_date,
|
'upload_date': upload_date,
|
||||||
'title': data['title'],
|
'title': data['title'],
|
||||||
'ext': ext,
|
|
||||||
'format': data['media']['mimeType'],
|
|
||||||
'thumbnail': data['thumbnailUrl'],
|
'thumbnail': data['thumbnailUrl'],
|
||||||
'description': data['description'],
|
'description': data['description'],
|
||||||
'player_url': data['embedUrl'],
|
|
||||||
'user_agent': 'iTunes/10.6.1',
|
'user_agent': 'iTunes/10.6.1',
|
||||||
|
'formats': formats,
|
||||||
}
|
}
|
||||||
except (ValueError, KeyError) as err:
|
except (ValueError, KeyError) as err:
|
||||||
raise ExtractorError(u'Unable to parse video information: %s' % repr(err))
|
raise ExtractorError(u'Unable to parse video information: %s' % repr(err))
|
||||||
|
|
Loading…
Reference in New Issue