]>
 
 
Raphaƫl G. Git Repositories - youtubedl/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' ,  
  34          'url' :  'http://testtube.com/brainstuff' ,  
  37              'title' :  'BrainStuff' ,  
  38              '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.' ,  
  40          'playlist_mincount' :  93 ,  
  42          'url' :  'https://testtube.com/dnews/5-weird-ways-plants-can-eat-animals?utm_source=FB&utm_medium=DNews&utm_campaign=DNewsSocial' ,  
  45              'display_id' :  'dnews/5-weird-ways-plants-can-eat-animals' ,  
  48              'title' :  '5 Weird Ways Plants Can Eat Animals' ,  
  49              'description' :  'Why have some plants evolved to eat meat?' ,  
  50              'upload_date' :  '20150120' ,  
  51              'timestamp' :  1421763300 ,  
  53              'uploader_id' :  'dnews' ,  
  56      _PAGE_DATA_TEMPLATE 
=  'http://www. %s /apiProxy/ddn/ %s ?domain= %s '  
  57      _API_KEY 
=  'ba9c741bce1b9d8e3defcc22193f3651b8867e62'  
  59      def  _real_extract ( self
,  url
):  
  60          domain
,  display_id 
=  re
. match ( self
._ VALID
_U RL
,  url
). groups ()  
  61          page_info 
=  self
._ download
_ json
(  
  62              self
._ PAGE
_ DATA
_ TEMPLATE 
% ( domain
,  display_id
,  domain
),  display_id
)  
  64          if  page_info
[ 'data' ][ 'type' ] ==  'episode' :  
  65              episode_data 
=  page_info
[ 'data' ]  
  66              video_id 
=  compat_str ( episode_data
[ 'video' ][ 'data' ][ 'id' ])  
  67              video_data 
=  self
._ download
_ json
(  
  68                  'http://revision3.com/api/getPlaylist.json?api_key= %s &codecs=h264,vp8,theora&video_id= %s '  % ( self
._ API
_ KEY
,  video_id
),  
  72              for  vcodec
,  media 
in  video_data
[ 'media' ]. items ():  
  73                  for  quality_id
,  quality 
in  media
. items ():  
  74                      if  quality_id 
==  'hls' :  
  75                          formats
. extend ( self
._ extract
_ m
3u8_ formats
(  
  76                              quality
[ 'url' ],  video_id
,  'mp4' ,  
  77                              'm3u8_native' ,  m3u8_id
= 'hls' ,  fatal
= False ))  
  80                              'url' :  quality
[ 'url' ],  
  81                              'format_id' :  ' %s-%s '  % ( vcodec
,  quality_id
),  
  82                              'tbr' :  int_or_none ( quality
. get ( 'bitrate' )),  
  85              self
._ sort
_ formats
( formats
)  
  87              preference 
=  qualities ([ 'mini' ,  'small' ,  'medium' ,  'large' ])  
  91                  'preference' :  preference ( image_id
)  
  92              }  for  image_id
,  image_url 
in  video_data
. get ( 'images' , {}). items ()]  
  96                  'display_id' :  display_id
,  
  97                  'title' :  unescapeHTML ( video_data
[ 'title' ]),  
  98                  'description' :  unescapeHTML ( video_data
. get ( 'summary' )),  
  99                  'timestamp' :  parse_iso8601 ( episode_data
. get ( 'publishTime' ),  ' ' ),  
 100                  'author' :  episode_data
. get ( 'author' ),  
 101                  'uploader' :  video_data
. get ( 'show' , {}). get ( 'name' ),  
 102                  'uploader_id' :  video_data
. get ( 'show' , {}). get ( 'slug' ),  
 103                  'duration' :  int_or_none ( video_data
. get ( 'duration' )),  
 104                  'thumbnails' :  thumbnails
,  
 108              show_data 
=  page_info
[ 'show' ][ 'data' ]  
 109              episodes_data 
=  page_info
[ 'episodes' ][ 'data' ]  
 110              num_episodes 
=  page_info
[ 'meta' ][ 'totalEpisodes' ]  
 111              processed_episodes 
=  0  
 115                  entries
. extend ([ self
. url_result (  
 116                      'http:// %s / %s / %s '  % ( domain
,  display_id
,  episode
[ 'slug' ]))  for  episode 
in  episodes_data
])  
 117                  processed_episodes 
+=  len ( episodes_data
)  
 118                  if  processed_episodes 
==  num_episodes
:  
 121                  episodes_data 
=  self
._ download
_ json
( self
._ PAGE
_ DATA
_ TEMPLATE 
% (  
 122                      domain
,  display_id 
+  '/'  +  compat_str ( page_num
),  domain
),  
 123                      display_id
)[ 'episodes' ][ 'data' ]  
 125              return  self
. playlist_result (  
 126                  entries
,  compat_str ( show_data
[ 'id' ]),  
 127                  show_data
. get ( 'name' ),  show_data
. get ( 'summary' ))