mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-03 08:19:57 +01:00
parent
1f8b4ab733
commit
5747d4f4e8
@ -1,5 +1,6 @@
|
|||||||
import re
|
|
||||||
import base64
|
import base64
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
@ -13,6 +14,7 @@
|
|||||||
int_or_none,
|
int_or_none,
|
||||||
unsmuggle_url,
|
unsmuggle_url,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
|
traverse_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ class KalturaIE(InfoExtractor):
|
|||||||
)
|
)
|
||||||
'''
|
'''
|
||||||
_SERVICE_URL = 'http://cdnapi.kaltura.com'
|
_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
|
# See https://github.com/kaltura/server/blob/master/plugins/content/caption/base/lib/model/enums/CaptionType.php
|
||||||
_CAPTION_TYPES = {
|
_CAPTION_TYPES = {
|
||||||
1: 'srt',
|
1: 'srt',
|
||||||
@ -169,30 +171,35 @@ def _extract_urls(webpage):
|
|||||||
|
|
||||||
def _kaltura_api_call(self, video_id, actions, service_url=None, *args, **kwargs):
|
def _kaltura_api_call(self, video_id, actions, service_url=None, *args, **kwargs):
|
||||||
params = actions[0]
|
params = actions[0]
|
||||||
if len(actions) > 1:
|
params.update({i: a for i, a in enumerate(actions[1:], start=1)})
|
||||||
for i, a in enumerate(actions[1:], start=1):
|
|
||||||
for k, v in a.items():
|
|
||||||
params['%d:%s' % (i, k)] = v
|
|
||||||
|
|
||||||
data = self._download_json(
|
data = self._download_json(
|
||||||
(service_url or self._SERVICE_URL) + self._SERVICE_BASE,
|
(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 status.get('objectType') == 'KalturaAPIException':
|
if not isinstance(status, dict):
|
||||||
raise ExtractorError(
|
continue
|
||||||
'%s said: %s' % (self.IE_NAME, status['message']))
|
if status.get('objectType') == 'KalturaAPIException':
|
||||||
|
raise ExtractorError(
|
||||||
|
'%s said: %s (%d)' % (self.IE_NAME, status['message'], idx))
|
||||||
|
|
||||||
|
data[1] = traverse_obj(data, (1, 'objects', 0))
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _get_video_info(self, video_id, partner_id, service_url=None):
|
def _get_video_info(self, video_id, partner_id, service_url=None):
|
||||||
actions = [
|
actions = [
|
||||||
{
|
{
|
||||||
'action': 'null',
|
'apiVersion': '3.3.0',
|
||||||
'apiVersion': '3.1.5',
|
'clientTag': 'html5:v3.1.0',
|
||||||
'clientTag': 'kdp:v3.8.5',
|
|
||||||
'format': 1, # JSON, 2 = XML, 3 = PHP
|
'format': 1, # JSON, 2 = XML, 3 = PHP
|
||||||
'service': 'multirequest',
|
'ks': '',
|
||||||
|
'partnerId': partner_id,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'expiry': 86400,
|
'expiry': 86400,
|
||||||
@ -201,12 +208,14 @@ def _get_video_info(self, video_id, partner_id, service_url=None):
|
|||||||
'widgetId': '_%s' % partner_id,
|
'widgetId': '_%s' % partner_id,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'action': 'get',
|
'action': 'list',
|
||||||
'entryId': video_id,
|
'filter': {'redirectFromEntryId': video_id},
|
||||||
'service': 'baseentry',
|
'service': 'baseentry',
|
||||||
'ks': '{1:result:ks}',
|
'ks': '{1:result:ks}',
|
||||||
'responseProfile:fields': 'createdAt,dataUrl,duration,name,plays,thumbnailUrl,userId',
|
'responseProfile': {
|
||||||
'responseProfile:type': 1,
|
'type': 1,
|
||||||
|
'fields': 'createdAt,dataUrl,duration,name,plays,thumbnailUrl,userId',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'action': 'getbyentryid',
|
'action': 'getbyentryid',
|
||||||
|
Loading…
Reference in New Issue
Block a user