-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathview.py
More file actions
71 lines (56 loc) · 2.64 KB
/
Copy pathview.py
File metadata and controls
71 lines (56 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from KalturaClient import *
from KalturaClient.Plugins.Core import *
from KalturaClient.Plugins.Schedule import *
import ks
import config
from urllib.parse import urlencode
from datetime import datetime, timedelta
class View:
@staticmethod
def playback(entry_id, uiconf_id):
client = ks.client_for_admin(config.admin_email, "")
livestream = client.liveStream.get(entry_id)
is_live = client.liveStream.isLive(entry_id, KalturaPlaybackProtocol.AUTO)
if (is_live == False):
if ((livestream.redirectEntryId) and livestream.redirectEntryId != ''):
entry_id = livestream.redirectEntryId
elif ((livestream.recordedEntryId) and livestream.recordedEntryId != ''):
entry_id = livestream.recordedEntryId
## for entries with PER_SESSION recording, the recordedEntryId is wiped
## we find the recorded entry by filtering on the root entry
else:
filter = KalturaBaseEntryFilter()
filter.rootEntryIdEqual = entry_id
pager = KalturaFilterPager()
result = client.baseEntry.list(filter, pager)
if (result.objects):
entry_id = result.objects[0].id
privileges = "sview:{},restrictexplicitliveview:{},enableentitlement,appid:{},appdomain:{},sessionkey:{}" \
.format(entry_id, entry_id, config.app_id, config.app_domain, config.viewer_user_id)
kaltura_session = ks.get_ks(config.viewer_user_id, privileges, KalturaSessionType.USER)
data = {
"ks": kaltura_session,
"partner_id": config.partner_id,
"uiconf_id": uiconf_id,
"user_id": config.viewer_user_id,
"entry_id": entry_id,
"app_name": config.app_name, #for player v2
}
return data
@staticmethod
def moderator_view(entry_id):
privileges = "setrole:WEBCAST_PRODUCER_DEVICE_ROLE,sview:*,list:{},download:{}" \
.format(entry_id, entry_id)
kaltura_session = ks.get_ks(config.moderator_user, privileges, KalturaSessionType.USER)
base_url = "https://www.kaltura.com/apps/webcast/vlatest/index.html?"
params = {
"MediaEntryId": entry_id,
"ks":kaltura_session,
"ks_expiry": datetime.now()+timedelta(days=1),
"qnaModeratorMode": True,
"serverAddress": config.service_url,
"fromDate": datetime.now()+timedelta(minutes=2),
"toDate":datetime.now()+timedelta(minutes=8)
}
moderator_url = base_url+urlencode(params)
return(moderator_url)