|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import re
|
|
|
|
|
import base64
|
|
|
|
|
import json
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
from ..compat import (
|
|
|
|
@ -13,6 +14,7 @@ from ..utils import (
|
|
|
|
|
int_or_none,
|
|
|
|
|
unsmuggle_url,
|
|
|
|
|
smuggle_url,
|
|
|
|
|
traverse_obj,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -33,7 +35,7 @@ class KalturaIE(InfoExtractor):
|
|
|
|
|
)
|
|
|
|
|
'''
|
|
|
|
|
_SERVICE_URL = 'http://cdnapi.kaltura.com'
|
|
|
|
|
_SERVICE_BASE = '/api_v3/index.php'
|
|
|
|
|
_SERVICE_BASE = '/api_v3/service/multirequest'
|
|
|
|
|
# See https://github.com/kaltura/server/blob/master/plugins/content/caption/base/lib/model/enums/CaptionType.php
|
|
|
|
|
_CAPTION_TYPES = {
|
|
|
|
|
1: 'srt',
|
|
|
|
@ -169,30 +171,35 @@ class KalturaIE(InfoExtractor):
|
|
|
|
|
|
|
|
|
|
def _kaltura_api_call(self, video_id, actions, service_url=None, *args, **kwargs):
|
|
|
|
|
params = actions[0]
|
|
|
|
|
if len(actions) > 1:
|
|
|
|
|
for i, a in enumerate(actions[1:], start=1):
|
|
|
|
|
for k, v in a.items():
|
|
|
|
|
params['%d:%s' % (i, k)] = v
|
|
|
|
|
params.update({i: a for i, a in enumerate(actions[1:], start=1)})
|
|
|
|
|
|
|
|
|
|
data = self._download_json(
|
|
|
|
|
(service_url or self._SERVICE_URL) + self._SERVICE_BASE,
|
|
|
|
|
video_id, query=params, *args, **kwargs)
|
|
|
|
|
video_id, data=json.dumps(params).encode('utf-8'),
|
|
|
|
|
headers={
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
|
|
|
}, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
for idx, status in enumerate(data):
|
|
|
|
|
if not isinstance(status, dict):
|
|
|
|
|
continue
|
|
|
|
|
if status.get('objectType') == 'KalturaAPIException':
|
|
|
|
|
raise ExtractorError(
|
|
|
|
|
'%s said: %s (%d)' % (self.IE_NAME, status['message'], idx))
|
|
|
|
|
|
|
|
|
|
status = data if len(actions) == 1 else data[0]
|
|
|
|
|
if status.get('objectType') == 'KalturaAPIException':
|
|
|
|
|
raise ExtractorError(
|
|
|
|
|
'%s said: %s' % (self.IE_NAME, status['message']))
|
|
|
|
|
data[1] = traverse_obj(data, (1, 'objects', 0))
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
def _get_video_info(self, video_id, partner_id, service_url=None):
|
|
|
|
|
actions = [
|
|
|
|
|
{
|
|
|
|
|
'action': 'null',
|
|
|
|
|
'apiVersion': '3.1.5',
|
|
|
|
|
'clientTag': 'kdp:v3.8.5',
|
|
|
|
|
'apiVersion': '3.3.0',
|
|
|
|
|
'clientTag': 'html5:v3.1.0',
|
|
|
|
|
'format': 1, # JSON, 2 = XML, 3 = PHP
|
|
|
|
|
'service': 'multirequest',
|
|
|
|
|
'ks': '',
|
|
|
|
|
'partnerId': partner_id,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'expiry': 86400,
|
|
|
|
@ -201,12 +208,14 @@ class KalturaIE(InfoExtractor):
|
|
|
|
|
'widgetId': '_%s' % partner_id,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'action': 'get',
|
|
|
|
|
'entryId': video_id,
|
|
|
|
|
'action': 'list',
|
|
|
|
|
'filter': {'redirectFromEntryId': video_id},
|
|
|
|
|
'service': 'baseentry',
|
|
|
|
|
'ks': '{1:result:ks}',
|
|
|
|
|
'responseProfile:fields': 'createdAt,dataUrl,duration,name,plays,thumbnailUrl,userId',
|
|
|
|
|
'responseProfile:type': 1,
|
|
|
|
|
'responseProfile': {
|
|
|
|
|
'type': 1,
|
|
|
|
|
'fields': 'createdAt,dataUrl,duration,name,plays,thumbnailUrl,userId',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'action': 'getbyentryid',
|
|
|
|
|