|
|
|
@ -6,13 +6,16 @@ from .common import InfoExtractor
|
|
|
|
|
from ..utils import (
|
|
|
|
|
int_or_none,
|
|
|
|
|
float_or_none,
|
|
|
|
|
ExtractorError,
|
|
|
|
|
unsmuggle_url,
|
|
|
|
|
)
|
|
|
|
|
from ..compat import compat_urllib_parse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OoyalaBaseIE(InfoExtractor):
|
|
|
|
|
|
|
|
|
|
def _extract(self, player_url, video_id):
|
|
|
|
|
content_tree = self._download_json(player_url, video_id)['content_tree']
|
|
|
|
|
def _extract(self, content_tree_url, video_id, domain='example.org'):
|
|
|
|
|
content_tree = self._download_json(content_tree_url, video_id)['content_tree']
|
|
|
|
|
metadata = content_tree[list(content_tree)[0]]
|
|
|
|
|
embed_code = metadata['embed_code']
|
|
|
|
|
pcode = metadata.get('asset_pcode') or embed_code
|
|
|
|
@ -27,11 +30,12 @@ class OoyalaBaseIE(InfoExtractor):
|
|
|
|
|
formats = []
|
|
|
|
|
for supported_format in ('mp4', 'm3u8', 'hds', 'rtmp'):
|
|
|
|
|
auth_data = self._download_json(
|
|
|
|
|
'http://player.ooyala.com/sas/player_api/v1/authorization/embed_code/%s/%s?domain=www.example.org&supportedFormats=%s' % (pcode, embed_code, supported_format),
|
|
|
|
|
'http://player.ooyala.com/sas/player_api/v1/authorization/embed_code/%s/%s?' % (pcode, embed_code) + compat_urllib_parse.urlencode({'domain': domain, 'supportedFormats': supported_format}),
|
|
|
|
|
video_id, 'Downloading %s JSON' % supported_format)
|
|
|
|
|
|
|
|
|
|
cur_auth_data = auth_data['authorization_data'][embed_code]
|
|
|
|
|
|
|
|
|
|
if cur_auth_data['authorized']:
|
|
|
|
|
for stream in cur_auth_data['streams']:
|
|
|
|
|
url = base64.b64decode(stream['url']['data'].encode('ascii')).decode('utf-8')
|
|
|
|
|
delivery_type = stream['delivery_type']
|
|
|
|
@ -54,6 +58,8 @@ class OoyalaBaseIE(InfoExtractor):
|
|
|
|
|
'vbr': int_or_none(stream.get('video_bitrate')),
|
|
|
|
|
'fps': float_or_none(stream.get('framerate')),
|
|
|
|
|
})
|
|
|
|
|
else:
|
|
|
|
|
raise ExtractorError('%s said: %s' % (self.IE_NAME, cur_auth_data['message']), expected=True)
|
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
video_info['formats'] = formats
|
|
|
|
@ -108,9 +114,11 @@ class OoyalaIE(OoyalaBaseIE):
|
|
|
|
|
ie=cls.ie_key())
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
url, smuggled_data = unsmuggle_url(url, {})
|
|
|
|
|
embed_code = self._match_id(url)
|
|
|
|
|
domain = smuggled_data.get('domain')
|
|
|
|
|
content_tree_url = 'http://player.ooyala.com/player_api/v1/content_tree/embed_code/%s/%s' % (embed_code, embed_code)
|
|
|
|
|
return self._extract(content_tree_url, embed_code)
|
|
|
|
|
return self._extract(content_tree_url, embed_code, domain)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OoyalaExternalIE(OoyalaBaseIE):
|
|
|
|
|