]>
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
16 class Revision3IE ( InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?(?P<domain>(?:revision3|testtube|animalist)\.com)/(?P<id>[^/]+(?:/[^/?#]+)?)'
19 'url' : 'http://www.revision3.com/technobuffalo/5-google-predictions-for-2016' ,
20 'md5' : 'd94a72d85d0a829766de4deb8daaf7df' ,
23 'display_id' : 'technobuffalo/5-google-predictions-for-2016' ,
25 'title' : '5 Google Predictions for 2016' ,
26 'description' : 'Google had a great 2015, but it \' s already time to look ahead. Here are our five predictions for 2016.' ,
27 'upload_date' : '20151228' ,
28 'timestamp' : 1451325600 ,
30 'uploader' : 'TechnoBuffalo' ,
31 'uploader_id' : 'technobuffalo' ,
35 'url' : 'http://testtube.com/brainstuff' ,
38 'title' : 'BrainStuff' ,
39 '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.' ,
41 'playlist_mincount' : 93 ,
43 'url' : 'https://testtube.com/dnews/5-weird-ways-plants-can-eat-animals?utm_source=FB&utm_medium=DNews&utm_campaign=DNewsSocial' ,
46 'display_id' : 'dnews/5-weird-ways-plants-can-eat-animals' ,
49 'title' : '5 Weird Ways Plants Can Eat Animals' ,
50 'description' : 'Why have some plants evolved to eat meat?' ,
51 'upload_date' : '20150120' ,
52 'timestamp' : 1421763300 ,
54 'uploader_id' : 'dnews' ,
57 'url' : 'http://testtube.com/tt-editors-picks/the-israel-palestine-conflict-explained-in-ten-min' ,
61 'display_id' : 'tt-editors-picks/the-israel-palestine-conflict-explained-in-ten-min' ,
62 'title' : 'The Israel-Palestine Conflict Explained in Ten Minutes' ,
63 'description' : 'If you \' d like to learn about the struggle between Israelis and Palestinians, this video is a great place to start' ,
64 'uploader' : 'Editors \' Picks' ,
65 'uploader_id' : 'tt-editors-picks' ,
66 'timestamp' : 1453309200 ,
67 'upload_date' : '20160120' ,
69 'add_ie' : [ 'Youtube' ],
72 'url' : 'http://testtube.com/tech-news' ,
77 'playlist_mincount' : 9 ,
79 _PAGE_DATA_TEMPLATE
= 'http://www. %s /apiProxy/ddn/ %s ?domain= %s '
80 _API_KEY
= 'ba9c741bce1b9d8e3defcc22193f3651b8867e62'
82 def _real_extract ( self
, url
):
83 domain
, display_id
= re
. match ( self
._ VALID
_U RL
, url
). groups ()
84 page_info
= self
._ download
_ json
(
85 self
._ PAGE
_ DATA
_ TEMPLATE
% ( domain
, display_id
, domain
), display_id
)
87 page_data
= page_info
[ 'data' ]
88 page_type
= page_data
[ 'type' ]
89 if page_type
in ( 'episode' , 'embed' ):
90 show_data
= page_data
[ 'show' ][ 'data' ]
91 video_id
= compat_str ( page_data
[ 'video' ][ 'data' ][ 'id' ])
93 preference
= qualities ([ 'mini' , 'small' , 'medium' , 'large' ])
97 'preference' : preference ( image_id
)
98 } for image_id
, image_url
in page_data
. get ( 'images' , {}). items ()]
102 'display_id' : display_id
,
103 'title' : unescapeHTML ( page_data
[ 'name' ]),
104 'description' : unescapeHTML ( page_data
. get ( 'summary' )),
105 'timestamp' : parse_iso8601 ( page_data
. get ( 'publishTime' ), ' ' ),
106 'author' : page_data
. get ( 'author' ),
107 'uploader' : show_data
. get ( 'name' ),
108 'uploader_id' : show_data
. get ( 'slug' ),
109 'thumbnails' : thumbnails
,
112 if page_type
== 'embed' :
114 '_type' : 'url_transparent' ,
115 'url' : page_data
[ 'video' ][ 'data' ][ 'embed' ],
119 video_data
= self
._ download
_ json
(
120 'http://revision3.com/api/getPlaylist.json?api_key= %s &codecs=h264,vp8,theora&video_id= %s ' % ( self
._ API
_ KEY
, video_id
),
121 video_id
)[ 'items' ][ 0 ]
124 for vcodec
, media
in video_data
[ 'media' ]. items ():
125 for quality_id
, quality
in media
. items ():
126 if quality_id
== 'hls' :
127 formats
. extend ( self
._ extract
_ m
3u8_ formats
(
128 quality
[ 'url' ], video_id
, 'mp4' ,
129 'm3u8_native' , m3u8_id
= 'hls' , fatal
= False ))
132 'url' : quality
[ 'url' ],
133 'format_id' : ' %s-%s ' % ( vcodec
, quality_id
),
134 'tbr' : int_or_none ( quality
. get ( 'bitrate' )),
137 self
._ sort
_ formats
( formats
)
140 'title' : unescapeHTML ( video_data
[ 'title' ]),
141 'description' : unescapeHTML ( video_data
. get ( 'summary' )),
142 'uploader' : video_data
. get ( 'show' , {}). get ( 'name' ),
143 'uploader_id' : video_data
. get ( 'show' , {}). get ( 'slug' ),
144 'duration' : int_or_none ( video_data
. get ( 'duration' )),
149 list_data
= page_info
[ page_type
][ 'data' ]
150 episodes_data
= page_info
[ 'episodes' ][ 'data' ]
151 num_episodes
= page_info
[ 'meta' ][ 'totalEpisodes' ]
152 processed_episodes
= 0
156 entries
. extend ([ self
. url_result (
157 'http:// %s%s ' % ( domain
, episode
[ 'path' ])) for episode
in episodes_data
])
158 processed_episodes
+= len ( episodes_data
)
159 if processed_episodes
== num_episodes
:
162 episodes_data
= self
._ download
_ json
( self
._ PAGE
_ DATA
_ TEMPLATE
% (
163 domain
, display_id
+ '/' + compat_str ( page_num
), domain
),
164 display_id
)[ 'episodes' ][ 'data' ]
166 return self
. playlist_result (
167 entries
, compat_str ( list_data
[ 'id' ]),
168 list_data
. get ( 'name' ), list_data
. get ( 'summary' ))