]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/revision3.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
7 from .. compat
import compat_str
15 class Revision3IE ( InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?(?P<domain>(?:revision3|testtube|animalist)\.com)/(?P<id>[^/]+(?:/[^/?#]+)?)'
18 'url' : 'http://www.revision3.com/technobuffalo/5-google-predictions-for-2016' ,
19 'md5' : 'd94a72d85d0a829766de4deb8daaf7df' ,
23 'title' : '5 Google Predictions for 2016' ,
24 'description' : 'Google had a great 2015, but it \' s already time to look ahead. Here are our five predictions for 2016.' ,
25 'upload_date' : '20151228' ,
26 'timestamp' : 1451325600 ,
30 'url' : 'http://testtube.com/brainstuff' ,
33 'title' : 'BrainStuff' ,
34 'description' : 'Whether the topic is popcorn or particle physics, you can count on the HowStuffWorks team to explore-and explain-the everyday science in the world around us on BrainStuff.' ,
36 'playlist_mincount' : 93 ,
38 _PAGE_DATA_TEMPLATE
= 'http://www. %s /apiProxy/ddn/ %s ?domain= %s '
39 _API_KEY
= 'ba9c741bce1b9d8e3defcc22193f3651b8867e62'
41 def _real_extract ( self
, url
):
42 domain
, display_id
= re
. match ( self
._ VALID
_U RL
, url
). groups ()
43 page_info
= self
._ download
_ json
(
44 self
._ PAGE
_ DATA
_ TEMPLATE
% ( domain
, display_id
, domain
), display_id
)
46 if page_info
[ 'data' ][ 'type' ] == 'episode' :
47 episode_data
= page_info
[ 'data' ]
48 video_id
= compat_str ( episode_data
[ 'video' ][ 'data' ][ 'id' ])
49 video_data
= self
._ download
_ json
(
50 'http://revision3.com/api/getPlaylist.json?api_key= %s &codecs=h264,vp8,theora&video_id= %s ' % ( self
._ API
_ KEY
, video_id
),
54 for media_type
, media
in video_data
[ 'media' ]. items ():
55 for quality_id
, quality
in media
. items ():
56 if quality_id
== 'hls' :
57 formats
. extend ( self
._ extract
_ m
3u8_ formats
(
58 quality
[ 'url' ], video_id
, 'mp4' ,
59 'm3u8_native' , m3u8_id
= 'hls' , fatal
= False ))
62 'url' : quality
[ 'url' ],
63 'format_id' : ' %s-%s ' % ( media_type
, quality_id
),
64 'tbr' : int_or_none ( quality
. get ( 'bitrate' )),
66 self
._ sort
_ formats
( formats
)
71 } for image_id
, image_url
in video_data
. get ( 'images' , {}). items ()]
75 'title' : unescapeHTML ( video_data
[ 'title' ]),
76 'description' : unescapeHTML ( video_data
. get ( 'summary' )),
77 'timestamp' : parse_iso8601 ( episode_data
. get ( 'publishTime' ), ' ' ),
78 'author' : episode_data
. get ( 'author' ),
79 'duration' : int_or_none ( video_data
. get ( 'duration' )),
80 'thumbnails' : thumbnails
,
84 show_data
= page_info
[ 'show' ][ 'data' ]
85 episodes_data
= page_info
[ 'episodes' ][ 'data' ]
86 num_episodes
= page_info
[ 'meta' ][ 'totalEpisodes' ]
87 processed_episodes
= 0
91 entries
. extend ([ self
. url_result (
92 url
+ '/ %s ' % episode
[ 'slug' ]) for episode
in episodes_data
])
93 processed_episodes
+= len ( episodes_data
)
94 if processed_episodes
== num_episodes
:
97 episodes_data
= self
._ download
_ json
( self
._ PAGE
_ DATA
_ TEMPLATE
% (
98 domain
, display_id
+ '/' + compat_str ( page_num
), domain
),
99 display_id
)[ 'episodes' ][ 'data' ]
101 return self
. playlist_result (
102 entries
, compat_str ( show_data
[ 'id' ]),
103 show_data
. get ( 'name' ), show_data
. get ( 'summary' ))