Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/yt-dlp/yt-dlp into ytdlp
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/yt-dlp/yt-dlp:
  Run `FFmpegFixupM3u8PP` for live-streams if needed
  [kaltura] Update API calls (#3657)
  • Loading branch information
Lesmiscore committed May 7, 2022
2 parents 1dfe2e4 + d7a1aa0 commit febb937
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
3 changes: 2 additions & 1 deletion yt_dlp/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -3341,7 +3341,8 @@ def ffmpeg_fixup(cndn, msg, cls):
downloader = downloader.__name__ if downloader else None

if info_dict.get('requested_formats') is None: # Not necessary if doing merger
ffmpeg_fixup(downloader == 'HlsFD',
live_fixup = info_dict.get('is_live') and not self.params.get('hls_use_mpegts')
ffmpeg_fixup(downloader == 'HlsFD' or live_fixup,
'Possible MPEG-TS in MP4 container or malformed AAC timestamps',
FFmpegFixupM3u8PP)
ffmpeg_fixup(info_dict.get('is_live') and downloader == 'DashSegmentsFD',
Expand Down
47 changes: 28 additions & 19 deletions yt_dlp/extractor/kaltura.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import base64
import json
import re

from .common import InfoExtractor
from ..compat import (
Expand All @@ -13,6 +14,7 @@
int_or_none,
unsmuggle_url,
smuggle_url,
traverse_obj,
)


Expand All @@ -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',
Expand Down Expand Up @@ -169,30 +171,35 @@ def _extract_urls(webpage):

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,
Expand All @@ -201,12 +208,14 @@ def _get_video_info(self, video_id, partner_id, service_url=None):
'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',
Expand Down

0 comments on commit febb937

Please sign in to comment.