]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/howstuffworks.py
1 from .common
import InfoExtractor
11 class HowStuffWorksIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://[\da-z-]+\.(?:howstuffworks|stuff(?:(?:youshould|theydontwantyouto)know|toblowyourmind|momnevertoldyou)|(?:brain|car)stuffshow|fwthinking|geniusstuff)\.com/(?:[^/]+/)*(?:\d+-)?(?P<id>.+?)-video\.htm'
15 'url': 'http://www.stufftoblowyourmind.com/videos/optical-illusions-video.htm',
16 'md5': '76646a5acc0c92bf7cd66751ca5db94d',
20 'title': 'Your Trickster Brain: Optical Illusions -- Science on the Web',
21 'description': 'md5:e374ff9561f6833ad076a8cc0a5ab2fb',
25 'url': 'http://shows.howstuffworks.com/more-shows/why-does-balloon-stick-to-hair-video.htm',
26 'only_matching': True,
30 def _real_extract(self
, url
):
31 display_id
= self
._match
_id
(url
)
32 webpage
= self
._download
_webpage
(url
, display_id
)
33 clip_js
= self
._search
_regex
(
34 r
'(?s)var clip = ({.*?});', webpage
, 'clip info')
35 clip_info
= self
._parse
_json
(
36 clip_js
, display_id
, transform_source
=js_to_json
)
38 video_id
= clip_info
['content_id']
40 m3u8_url
= clip_info
.get('m3u8')
41 if m3u8_url
and determine_ext(m3u8_url
) == 'm3u8':
42 formats
.extend(self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, 'mp4', format_id
='hls', fatal
=True))
43 flv_url
= clip_info
.get('flv_url')
49 for video
in clip_info
.get('mp4', []):
52 'format_id': 'mp4-%s' % video
['bitrate'],
53 'vbr': int_or_none(video
['bitrate'].rstrip('k')),
57 smil
= self
._download
_xml
(
58 'http://services.media.howstuffworks.com/videos/%s/smil-service.smil' % video_id
,
59 video_id
, 'Downloading video SMIL')
61 http_base
= find_xpath_attr(
63 './{0}head/{0}meta'.format('{http://www.w3.org/2001/SMIL20/Language}'),
65 'httpBase').get('content')
67 URL_SUFFIX
= '?v=2.11.3&fp=LNX 11,2,202,356&r=A&g=A'
69 for video
in smil
.findall(
70 './{0}body/{0}switch/{0}video'.format('{http://www.w3.org/2001/SMIL20/Language}')):
71 vbr
= int_or_none(video
.attrib
['system-bitrate'], scale
=1000)
73 'url': '%s/%s%s' % (http_base
, video
.attrib
['src'], URL_SUFFIX
),
74 'format_id': '%dk' % vbr
,
78 self
._sort
_formats
(formats
)
81 'id': '%s' % video_id
,
82 'display_id': display_id
,
83 'title': unescapeHTML(clip_info
['clip_title']),
84 'description': unescapeHTML(clip_info
.get('caption')),
85 'thumbnail': clip_info
.get('video_still_url'),
86 'duration': int_or_none(clip_info
.get('duration')),