]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/howstuffworks.py
1 from __future__
import unicode_literals
3 from . common
import InfoExtractor
6 class HowStuffWorksIE ( InfoExtractor
):
7 _VALID_URL
= r
'https?://[\da-z-]+\.howstuffworks\.com/(?:[^/]+/)*\d+-(?P<id>.+?)-video\.htm'
10 'url' : 'http://adventure.howstuffworks.com/39521-deadliest-catch-nautical-collision-video.htm' ,
14 'title' : 'Deadliest Catch: Nautical Collision' ,
15 'description' : 'Check out this clip to get an exclusive look at the Deadliest Catch crew back in action.' ,
16 'thumbnail' : 'http://s.hswstatic.com/gif/videos/480x360/39521.jpg' ,
20 'url' : 'http://adventure.howstuffworks.com/7199-survival-zone-food-and-water-in-the-savanna-video.htm' ,
24 'title' : 'Survival Zone: Food and Water In the Savanna' ,
25 'description' : 'Learn how to find both food and water while trekking in the African savannah. In this video from the Discovery Channel.' ,
26 'thumbnail' : 'http://s.hswstatic.com/gif/videos/480x360/7199.jpg' ,
30 'url' : 'http://entertainment.howstuffworks.com/arts/34476-time-warp-fire-breathing-disaster-video.htm' ,
34 'title' : 'Time Warp: Fire-Breathing Disaster' ,
35 'description' : 'Fire-breathers are safe from flames when they angle their heads up as they blow -- see what would happen if they looked down instead. Check out this clip from Discovery \' s "Time Warp" series to learn more.' ,
36 'thumbnail' : 'http://s.hswstatic.com/gif/videos/480x360/34476.jpg' ,
41 def _extract_clip_info ( self
, key
, clip_info
, name
= None , ** kargs
):
44 return self
._ html
_ search
_ regex
(
45 r
"\s* %s \s*: '?([^'\n]*[^'\n,])" % key
, clip_info
, name
, ** kargs
)
47 def _real_extract ( self
, url
):
48 display_id
= self
._ match
_ id
( url
)
49 webpage
= self
._ download
_ webpage
( url
, display_id
)
50 clip_info
= self
._ search
_ regex
( '(?s)var clip = {(.*?)} ;' , webpage
, 'clip info' )
51 video_id
= self
._ extract
_ clip
_ info
( 'content_id' , clip_info
, 'video id' )
53 m3u8_url
= self
._ extract
_ clip
_ info
( 'm3u8' , clip_info
, 'm3u8 url' , default
= None )
54 if m3u8_url
is not None :
55 formats
+= self
._ extract
_ m
3u8_ formats
( m3u8_url
, video_id
, 'mp4' )
56 mp4
= self
._ parse
_ json
(
57 self
._ extract
_ clip
_ info
(
58 'mp4' , clip_info
, 'formats' ). replace ( '},]' , '}]' ), video_id
)
62 'format_id' : video
[ 'bitrate' ],
63 'tbr' : int ( video
[ 'bitrate' ]. rstrip ( 'k' )),
65 self
._ sort
_ formats
( formats
)
69 'display_id' : display_id
,
70 'title' : self
._ extract
_ clip
_ info
( 'clip_title' , clip_info
, 'title' ),
71 'description' : self
._ extract
_ clip
_ info
( 'caption' , clip_info
, 'description' , fatal
= False ),
72 'thumbnail' : self
._ extract
_ clip
_ info
( 'video_still_url' , clip_info
, 'thumbnail' ),
73 'duration' : self
._ extract
_ clip
_ info
( 'duration' , clip_info
),