[howstuffworks] improve extraction

This commit is contained in:
remitamine 2016-03-31 21:09:27 +01:00
parent 5b012dfce8
commit 4ecc1fc638
1 changed files with 13 additions and 6 deletions

View File

@ -6,6 +6,7 @@ from ..utils import (
int_or_none, int_or_none,
js_to_json, js_to_json,
unescapeHTML, unescapeHTML,
determine_ext,
) )
@ -39,7 +40,7 @@ class HowStuffWorksIE(InfoExtractor):
'url': 'http://entertainment.howstuffworks.com/arts/2706-sword-swallowing-1-by-dan-meyer-video.htm', 'url': 'http://entertainment.howstuffworks.com/arts/2706-sword-swallowing-1-by-dan-meyer-video.htm',
'info_dict': { 'info_dict': {
'id': '440011', 'id': '440011',
'ext': 'flv', 'ext': 'mp4',
'title': 'Sword Swallowing #1 by Dan Meyer', 'title': 'Sword Swallowing #1 by Dan Meyer',
'description': 'Video footage (1 of 3) used by permission of the owner Dan Meyer through Sword Swallowers Association International <www.swordswallow.org>', 'description': 'Video footage (1 of 3) used by permission of the owner Dan Meyer through Sword Swallowers Association International <www.swordswallow.org>',
'display_id': 'sword-swallowing-1-by-dan-meyer', 'display_id': 'sword-swallowing-1-by-dan-meyer',
@ -63,13 +64,19 @@ class HowStuffWorksIE(InfoExtractor):
video_id = clip_info['content_id'] video_id = clip_info['content_id']
formats = [] formats = []
m3u8_url = clip_info.get('m3u8') m3u8_url = clip_info.get('m3u8')
if m3u8_url: if m3u8_url and determine_ext(m3u8_url) == 'm3u8':
formats += self._extract_m3u8_formats(m3u8_url, video_id, 'mp4') formats.extend(self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', format_id='hls', fatal=True))
flv_url = clip_info.get('flv_url')
if flv_url:
formats.append({
'url': flv_url,
'format_id': 'flv',
})
for video in clip_info.get('mp4', []): for video in clip_info.get('mp4', []):
formats.append({ formats.append({
'url': video['src'], 'url': video['src'],
'format_id': video['bitrate'], 'format_id': 'mp4-%s' % video['bitrate'],
'vbr': int(video['bitrate'].rstrip('k')), 'vbr': int_or_none(video['bitrate'].rstrip('k')),
}) })
if not formats: if not formats:
@ -102,6 +109,6 @@ class HowStuffWorksIE(InfoExtractor):
'title': unescapeHTML(clip_info['clip_title']), 'title': unescapeHTML(clip_info['clip_title']),
'description': unescapeHTML(clip_info.get('caption')), 'description': unescapeHTML(clip_info.get('caption')),
'thumbnail': clip_info.get('video_still_url'), 'thumbnail': clip_info.get('video_still_url'),
'duration': clip_info.get('duration'), 'duration': int_or_none(clip_info.get('duration')),
'formats': formats, 'formats': formats,
} }