[kaltura] Update API calls (#3657)

Authored by: flashdagger
This commit is contained in:
MMM 2022-05-07 18:06:05 +02:00 committed by GitHub
parent 1f8b4ab733
commit 5747d4f4e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
status = data if len(actions) == 1 else data[0]
for idx, status in enumerate(data):
if not isinstance(status, dict):
continue
if status.get('objectType') == 'KalturaAPIException':
raise ExtractorError(
'%s said: %s' % (self.IE_NAME, status['message']))
'%s said: %s (%d)' % (self.IE_NAME, status['message'], idx))
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',