2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class UplynkIE(InfoExtractor):
15 _VALID_URL = r'https?://.*?\.uplynk\.com/(?P<path>ext/[0-9a-f]{32}/(?P<external_id>[^/?&]+)|(?P<id>[0-9a-f]{32}))\.(?:m3u8|json)(?:.*?\bpbs=(?P<session_id>[^&]+))?'
17 'url': 'http://content.uplynk.com/e89eaf2ce9054aa89d92ddb2d817a52e.m3u8',
19 'id': 'e89eaf2ce9054aa89d92ddb2d817a52e',
21 'title': '030816-kgo-530pm-solar-eclipse-vid_web.mp4',
22 'uploader_id': '4413701bf5a1488db55b767f8ae9d4fa',
26 'skip_download': True,
30 def _extract_uplynk_info(self, uplynk_content_url):
31 path, external_id, video_id, session_id = re.match(UplynkIE._VALID_URL, uplynk_content_url).groups()
32 display_id = video_id or external_id
33 formats = self._extract_m3u8_formats('http://content.uplynk.com/%s.m3u8' % path, display_id, 'mp4')
36 f['extra_param_to_segment_url'] = 'pbs=' + session_id
37 self._sort_formats(formats)
38 asset = self._download_json('http://content.uplynk.com/player/assetinfo/%s.json' % path, display_id)
39 if asset.get('error') == 1:
40 raise ExtractorError('% said: %s' % (self.IE_NAME, asset['msg']), expected=True)
44 'title': asset['desc'],
45 'thumbnail': asset.get('default_poster_url'),
46 'duration': float_or_none(asset.get('duration')),
47 'uploader_id': asset.get('owner'),
51 def _real_extract(self, url):
52 return self._extract_uplynk_info(url)
55 class UplynkPreplayIE(UplynkIE):
56 IE_NAME = 'uplynk:preplay'
57 _VALID_URL = r'https?://.*?\.uplynk\.com/preplay2?/(?P<path>ext/[0-9a-f]{32}/(?P<external_id>[^/?&]+)|(?P<id>[0-9a-f]{32}))\.json'
60 def _real_extract(self, url):
61 path, external_id, video_id = re.match(self._VALID_URL, url).groups()
62 display_id = video_id or external_id
63 preplay = self._download_json(url, display_id)
64 content_url = 'http://content.uplynk.com/%s.m3u8' % path
65 session_id = preplay.get('sid')
67 content_url += '?pbs=' + session_id
68 return self._extract_uplynk_info(content_url)