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,
52 def _real_extract(self, url):
53 video_id = self._match_id(url)
55 data = self._download_json(
56 'http://www.azubu.tv/api/video/%s' % video_id, video_id)['data']
58 title = data['title'].strip()
59 description = data['description']
60 thumbnail = data['thumbnail']
61 view_count = data['view_count']
62 uploader = data['user']['username']
63 uploader_id = data['user']['id']
65 stream_params = json.loads(data['stream_params'])
67 timestamp = float_or_none(stream_params['creationDate'], 1000)
68 duration = float_or_none(stream_params['length'], 1000)
70 renditions = stream_params.get('renditions') or []
71 video = stream_params.get('FLVFullLength') or stream_params.get('videoFullLength')
73 renditions.append(video)
77 'width': fmt['frameWidth'],
78 'height': fmt['frameHeight'],
79 'vbr': float_or_none(fmt['encodingRate'], 1000),
80 'filesize': fmt['size'],
81 'vcodec': fmt['videoCodec'],
82 'container': fmt['videoContainer'],
83 } for fmt in renditions if fmt['url']]
84 self._sort_formats(formats)
89 'description': description,
90 'thumbnail': thumbnail,
91 'timestamp': timestamp,
94 'uploader_id': uploader_id,
95 'view_count': view_count,
100 class AzubuLiveIE(InfoExtractor):
101 _VALID_URL = r'https?://www.azubu.tv/(?P<id>[^/]+)$'
104 'url': 'http://www.azubu.tv/MarsTVMDLen',
105 'only_matching': True,
108 def _real_extract(self, url):
109 user = self._match_id(url)
111 info = self._download_json(
112 'http://api.azubu.tv/public/modules/last-video/{0}/info'.format(user),
114 if info['type'] != 'STREAM':
115 raise ExtractorError('{0} is not streaming live'.format(user), expected=True)
117 req = sanitized_Request(
118 'https://edge-elb.api.brightcove.com/playback/v1/accounts/3361910549001/videos/ref:' + info['reference_id'])
119 req.add_header('Accept', 'application/json;pk=BCpkADawqM1gvI0oGWg8dxQHlgT8HkdE2LnAlWAZkOlznO39bSZX726u4JqnDsK3MDXcO01JxXK2tZtJbgQChxgaFzEVdHRjaDoxaOu8hHOO8NYhwdxw9BzvgkvLUlpbDNUuDoc4E4wxDToV')
120 bc_info = self._download_json(req, user)
121 m3u8_url = next(source['src'] for source in bc_info['sources'] if source['container'] == 'M2TS')
122 formats = self._extract_m3u8_formats(m3u8_url, user, ext='mp4')
123 self._sort_formats(formats)
127 'title': self._live_title(info['title']),
131 'thumbnail': bc_info['poster'],