]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/kaltura.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_urllib_parse
14 class KalturaIE(InfoExtractor
):
17 kaltura:(?P<partner_id_s>\d+):(?P<id_s>[0-9a-z_]+)|
19 (:?(?:www|cdnapisec)\.)?kaltura\.com/
24 (?:[^/]+/)*?wid/_(?P<partner_id>\d+)/
25 (?:[^/]+/)*?entry_id/(?P<id>[0-9a-z_]+)|
28 (?:[^/]+/)*?entry_id/(?P<id_html5>[0-9a-z_]+)
29 .*\?.*\bwid=_(?P<partner_id_html5>\d+)
34 _API_BASE
= 'http://cdnapi.kaltura.com/api_v3/index.php?'
37 'url': 'kaltura:269692:1_1jc2y3e4',
38 'md5': '3adcbdb3dcc02d647539e53f284ba171',
43 'upload_date': '20131219',
44 'uploader_id': 'mlundberg@wolfgangsvault.com',
45 'description': 'The Allman Brothers Band, 12/16/1981',
46 'thumbnail': 're:^https?://.*/thumbnail/.*',
51 'url': 'http://www.kaltura.com/index.php/kwidget/cache_st/1300318621/wid/_269692/uiconf_id/3873291/entry_id/1_1jc2y3e4',
52 'only_matching': True,
55 'url': 'https://cdnapisec.kaltura.com/index.php/kwidget/wid/_557781/uiconf_id/22845202/entry_id/1_plr1syf3',
56 'only_matching': True,
59 'url': 'https://cdnapisec.kaltura.com/html5/html5lib/v2.30.2/mwEmbedFrame.php/p/1337/uiconf_id/20540612/entry_id/1_sf5ovm7u?wid=_243342',
60 'only_matching': True,
64 def _kaltura_api_call(self
, video_id
, actions
, *args
, **kwargs
):
67 for i
, a
in enumerate(actions
[1:], start
=1):
68 for k
, v
in a
.items():
69 params
['%d:%s' % (i
, k
)] = v
71 query
= compat_urllib_parse
.urlencode(params
)
72 url
= self
._API
_BASE
+ query
73 data
= self
._download
_json
(url
, video_id
, *args
, **kwargs
)
75 status
= data
if len(actions
) == 1 else data
[0]
76 if status
.get('objectType') == 'KalturaAPIException':
78 '%s said: %s' % (self
.IE_NAME
, status
['message']))
82 def _get_kaltura_signature(self
, video_id
, partner_id
):
88 'action': 'startWidgetSession',
89 'widgetId': '_%s' % partner_id
,
91 return self
._kaltura
_api
_call
(
92 video_id
, actions
, note
='Downloading Kaltura signature')['ks']
94 def _get_video_info(self
, video_id
, partner_id
):
95 signature
= self
._get
_kaltura
_signature
(video_id
, partner_id
)
99 'apiVersion': '3.1.5',
100 'clientTag': 'kdp:v3.8.5',
101 'format': 1, # JSON, 2 = XML, 3 = PHP
102 'service': 'multirequest',
108 'service': 'baseentry',
112 'action': 'getContextData',
113 'contextDataParams:objectType': 'KalturaEntryContextDataParams',
114 'contextDataParams:referrer': 'http://www.kaltura.com/',
115 'contextDataParams:streamerType': 'http',
117 'service': 'baseentry',
120 return self
._kaltura
_api
_call
(
121 video_id
, actions
, note
='Downloading video info JSON')
123 def _real_extract(self
, url
):
124 mobj
= re
.match(self
._VALID
_URL
, url
)
125 partner_id
= mobj
.group('partner_id_s') or mobj
.group('partner_id') or mobj
.group('partner_id_html5')
126 entry_id
= mobj
.group('id_s') or mobj
.group('id') or mobj
.group('id_html5')
128 info
, source_data
= self
._get
_video
_info
(entry_id
, partner_id
)
131 'format_id': '%(fileExt)s-%(bitrate)s' % f
,
134 'fps': f
.get('frameRate'),
135 'filesize_approx': int_or_none(f
.get('size'), invscale
=1024),
136 'container': f
.get('containerFormat'),
137 'vcodec': f
.get('videoCodecId'),
138 'height': f
.get('height'),
139 'width': f
.get('width'),
140 'url': '%s/flavorId/%s' % (info
['dataUrl'], f
['id']),
141 } for f
in source_data
['flavorAssets']]
142 self
._sort
_formats
(formats
)
146 'title': info
['name'],
148 'description': info
.get('description'),
149 'thumbnail': info
.get('thumbnailUrl'),
150 'duration': info
.get('duration'),
151 'timestamp': info
.get('createdAt'),
152 'uploader_id': info
.get('userId'),
153 'view_count': info
.get('plays'),