Skip to content

Commit 3a1c1d0

Browse files
codedsunpavnesh-c
andauthored
fix: stream.extra not none in BBB video recordings (fossasia#8379)
Co-authored-by: Pavnesh Chaturvedi <56963647+pc-beast@users.noreply.github.com>
1 parent 1d25fb2 commit 3a1c1d0

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

app/api/video_recordings.py

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,48 @@ def before_get(self, args, kwargs):
1919
if kwargs.get('video_stream_id'):
2020
stream = safe_query_kwargs(VideoStream, kwargs, 'video_stream_id', 'id')
2121

22-
if not has_access('is_organizer', event_id=stream.event_id):
23-
raise ForbiddenError(
24-
{'pointer': 'event_id'},
25-
'You need to be the event organizer to access video recordings.',
26-
)
22+
if stream.channel and stream.channel.provider == 'bbb':
23+
if not has_access('is_organizer', event_id=stream.event_id):
24+
raise ForbiddenError(
25+
{'pointer': 'event_id'},
26+
'You need to be the event organizer to access video recordings.',
27+
)
2728

28-
params = dict(
29-
meetingID=stream.extra['response']['meetingID'],
30-
)
31-
channel = stream.channel
32-
bbb = BigBlueButton(channel.api_url, channel.api_key)
33-
result = bbb.request('getRecordings', params)
34-
35-
if result.data['response']['recordings']:
36-
recordings = []
37-
if type(result.data['response']['recordings']['recording']) is list:
38-
recordings = result.data['response']['recordings']['recording']
39-
else:
40-
recordings.append(result.data['response']['recordings']['recording'])
41-
for recording in recordings:
42-
get_or_create(
43-
VideoRecording,
44-
bbb_record_id=recording['recordID'],
45-
participants=recording['participants'],
46-
url=recording['playback']['format']['url'],
47-
start_time=datetime.fromtimestamp(
48-
int(int(recording['startTime']) / 1000)
49-
),
50-
end_time=datetime.fromtimestamp(
51-
int(int(recording['endTime']) / 1000)
52-
),
53-
video_stream=stream,
29+
if stream.extra is not None:
30+
params = dict(
31+
meetingID=stream.extra['response']['meetingID'],
5432
)
33+
channel = stream.channel
34+
bbb = BigBlueButton(channel.api_url, channel.api_key)
35+
result = bbb.request('getRecordings', params)
36+
37+
if result.data['response']['recordings']:
38+
recordings = []
39+
if (
40+
type(result.data['response']['recordings']['recording'])
41+
is list
42+
):
43+
recordings = result.data['response']['recordings'][
44+
'recording'
45+
]
46+
else:
47+
recordings.append(
48+
result.data['response']['recordings']['recording']
49+
)
50+
for recording in recordings:
51+
get_or_create(
52+
VideoRecording,
53+
bbb_record_id=recording['recordID'],
54+
participants=recording['participants'],
55+
url=recording['playback']['format']['url'],
56+
start_time=datetime.fromtimestamp(
57+
int(int(recording['startTime']) / 1000)
58+
),
59+
end_time=datetime.fromtimestamp(
60+
int(int(recording['endTime']) / 1000)
61+
),
62+
video_stream=stream,
63+
)
5564

5665
def query(self, view_kwargs):
5766
query_ = VideoRecording.query

0 commit comments

Comments
 (0)