]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/blinkx.py
   1 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  12 class BlinkxIE(InfoExtractor
): 
  13     _VALID_URL 
= r
'^(?:https?://(?:www\.)blinkx\.com/#?ce/|blinkx:)(?P<id>[^?]+)' 
  17         'url': 'http://www.blinkx.com/ce/8aQUy7GVFYgFzpKhT0oqsilwOGFRVXk3R1ZGWWdGenBLaFQwb3FzaWx3OGFRVXk3R1ZGWWdGenB', 
  18         'file': '8aQUy7GV.mp4', 
  19         'md5': '2e9a07364af40163a908edbf10bb2492', 
  21             'title': 'Police Car Rolls Away', 
  22             'uploader': 'stupidvideos.com', 
  23             'upload_date': '20131215', 
  24             'timestamp': 1387068000, 
  25             'description': 'A police car gently rolls away from a fight. Maybe it felt weird being around a confrontation and just had to get out of there!', 
  30                 'url': 'http://cdn.blinkx.com/stream/b/41/StupidVideos/20131215/1873969261/1873969261_tn_0.jpg', 
  35     def _real_extract(self
, rl
): 
  36         m 
= re
.match(self
._VALID
_URL
, rl
) 
  37         video_id 
= m
.group('id') 
  38         display_id 
= video_id
[:8] 
  40         api_url 
= (u
'https://apib4.blinkx.com/api.php?action=play_video&' + 
  41                    'video=%s' % video_id
) 
  42         data_json 
= self
._download
_webpage
(api_url
, display_id
) 
  43         data 
= json
.loads(data_json
)['api']['results'][0] 
  47         for m 
in data
['media']: 
  48             if m
['type'] == 'jpg': 
  52                     'height': int(m
['h']), 
  54             elif m
['type'] == 'original': 
  56             elif m
['type'] == 'youtube': 
  58                 self
.to_screen(u
'Youtube video detected: %s' % yt_id
) 
  59                 return self
.url_result(yt_id
, 'Youtube', video_id
=yt_id
) 
  60             elif m
['type'] in ('flv', 'mp4'): 
  61                 vcodec 
= remove_start(m
['vcodec'], 'ff') 
  62                 acodec 
= remove_start(m
['acodec'], 'ff') 
  63                 tbr 
= (int(m
['vbr']) + int(m
['abr'])) // 1000 
  64                 format_id 
= u
'%s-%sk-%s' % (vcodec
, tbr
, m
['w']) 
  66                     'format_id': format_id
, 
  70                     'abr': int(m
['abr']) // 1000, 
  71                     'vbr': int(m
['vbr']) // 1000, 
  74                     'height': int(m
['h']), 
  77         self
._sort
_formats
(formats
) 
  82             'title': data
['title'], 
  84             'uploader': data
['channel_name'], 
  85             'timestamp': data
['pubdate_epoch'], 
  86             'description': data
.get('description'), 
  87             'thumbnails': thumbnails
,