]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/azubu.py
3ba2f00d39dc7836a3bfeddb8ca1da3e929e6e88
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
13 class AzubuIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?azubu\.(?:tv|uol.com.br)/[^/]+#!/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': r
'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': r
'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|uol.com.br)/(?P<id>[^/]+)$'
109 'url': 'http://www.azubu.tv/MarsTVMDLen',
110 'only_matching': True,
112 'url': 'http://azubu.uol.com.br/adolfz',
113 'only_matching': True,
116 def _real_extract(self
, url
):
117 user
= self
._match
_id
(url
)
119 info
= self
._download
_json
(
120 'http://api.azubu.tv/public/modules/last-video/{0}/info'.format(user
),
122 if info
['type'] != 'STREAM':
123 raise ExtractorError('{0} is not streaming live'.format(user
), expected
=True)
125 req
= sanitized_Request(
126 'https://edge-elb.api.brightcove.com/playback/v1/accounts/3361910549001/videos/ref:' + info
['reference_id'])
127 req
.add_header('Accept', 'application/json;pk=BCpkADawqM1gvI0oGWg8dxQHlgT8HkdE2LnAlWAZkOlznO39bSZX726u4JqnDsK3MDXcO01JxXK2tZtJbgQChxgaFzEVdHRjaDoxaOu8hHOO8NYhwdxw9BzvgkvLUlpbDNUuDoc4E4wxDToV')
128 bc_info
= self
._download
_json
(req
, user
)
129 m3u8_url
= next(source
['src'] for source
in bc_info
['sources'] if source
['container'] == 'M2TS')
130 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, user
, ext
='mp4')
131 self
._sort
_formats
(formats
)
135 'title': self
._live
_title
(info
['title']),
139 'thumbnail': bc_info
['poster'],