]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/azubu.py
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
  13 class AzubuIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://(?:www\.)?azubu\.tv/[^/]+#!/play/(?P<id>\d+)' 
  17             'url': 'http://www.azubu.tv/GSL#!/play/15575/2014-hot6-cup-last-big-match-ro8-day-1', 
  18             'md5': 'a88b42fcf844f29ad6035054bd9ecaf4', 
  22                 'title': '2014 HOT6 CUP LAST BIG MATCH Ro8 Day 1', 
  23                 'description': 'md5:d06bdea27b8cc4388a90ad35b5c66c01', 
  24                 'thumbnail': 're:^https?://.*\.jpe?g', 
  25                 'timestamp': 1417523507.334, 
  26                 'upload_date': '20141202', 
  29                 'uploader_id': 414310, 
  34             'url': 'http://www.azubu.tv/FnaticTV#!/play/9344/-fnatic-at-worlds-2014:-toyz---%22i-love-rekkles,-he-has-amazing-mechanics%22-', 
  35             'md5': 'b72a871fe1d9f70bd7673769cdb3b925', 
  39                 'title': 'Fnatic at Worlds 2014: Toyz - "I love Rekkles, he has amazing mechanics"', 
  40                 'description': 'md5:4a649737b5f6c8b5c5be543e88dc62af', 
  41                 'thumbnail': 're:^https?://.*\.jpe?g', 
  42                 'timestamp': 1410530893.320, 
  43                 'upload_date': '20140912', 
  45                 'uploader': 'FnaticTV', 
  46                 'uploader_id': 272749, 
  49             'skip': 'Channel offline', 
  53     def _real_extract(self
, url
): 
  54         video_id 
= self
._match
_id
(url
) 
  56         data 
= self
._download
_json
( 
  57             'http://www.azubu.tv/api/video/%s' % video_id
, video_id
)['data'] 
  59         title 
= data
['title'].strip() 
  60         description 
= data
.get('description') 
  61         thumbnail 
= data
.get('thumbnail') 
  62         view_count 
= data
.get('view_count') 
  63         user 
= data
.get('user', {}) 
  64         uploader 
= user
.get('username') 
  65         uploader_id 
= user
.get('id') 
  67         stream_params 
= json
.loads(data
['stream_params']) 
  69         timestamp 
= float_or_none(stream_params
.get('creationDate'), 1000) 
  70         duration 
= float_or_none(stream_params
.get('length'), 1000) 
  72         renditions 
= stream_params
.get('renditions') or [] 
  73         video 
= stream_params
.get('FLVFullLength') or stream_params
.get('videoFullLength') 
  75             renditions
.append(video
) 
  77         if not renditions 
and not user
.get('channel', {}).get('is_live', True): 
  78             raise ExtractorError('%s said: channel is offline.' % self
.IE_NAME
, expected
=True) 
  82             'width': fmt
['frameWidth'], 
  83             'height': fmt
['frameHeight'], 
  84             'vbr': float_or_none(fmt
['encodingRate'], 1000), 
  85             'filesize': fmt
['size'], 
  86             'vcodec': fmt
['videoCodec'], 
  87             'container': fmt
['videoContainer'], 
  88         } for fmt 
in renditions 
if fmt
['url']] 
  89         self
._sort
_formats
(formats
) 
  94             'description': description
, 
  95             'thumbnail': thumbnail
, 
  96             'timestamp': timestamp
, 
  99             'uploader_id': uploader_id
, 
 100             'view_count': view_count
, 
 105 class AzubuLiveIE(InfoExtractor
): 
 106     _VALID_URL 
= r
'https?://www.azubu.tv/(?P<id>[^/]+)$' 
 109         'url': 'http://www.azubu.tv/MarsTVMDLen', 
 110         'only_matching': True, 
 113     def _real_extract(self
, url
): 
 114         user 
= self
._match
_id
(url
) 
 116         info 
= self
._download
_json
( 
 117             'http://api.azubu.tv/public/modules/last-video/{0}/info'.format(user
), 
 119         if info
['type'] != 'STREAM': 
 120             raise ExtractorError('{0} is not streaming live'.format(user
), expected
=True) 
 122         req 
= sanitized_Request( 
 123             'https://edge-elb.api.brightcove.com/playback/v1/accounts/3361910549001/videos/ref:' + info
['reference_id']) 
 124         req
.add_header('Accept', 'application/json;pk=BCpkADawqM1gvI0oGWg8dxQHlgT8HkdE2LnAlWAZkOlznO39bSZX726u4JqnDsK3MDXcO01JxXK2tZtJbgQChxgaFzEVdHRjaDoxaOu8hHOO8NYhwdxw9BzvgkvLUlpbDNUuDoc4E4wxDToV') 
 125         bc_info 
= self
._download
_json
(req
, user
) 
 126         m3u8_url 
= next(source
['src'] for source 
in bc_info
['sources'] if source
['container'] == 'M2TS') 
 127         formats 
= self
._extract
_m
3u8_formats
(m3u8_url
, user
, ext
='mp4') 
 128         self
._sort
_formats
(formats
) 
 132             'title': self
._live
_title
(info
['title']), 
 136             'thumbnail': bc_info
['poster'],