18
18
from videodb .video import Video
19
19
from videodb .audio import Audio
20
20
from videodb .image import Image
21
+ from videodb .meeting import Meeting
21
22
22
23
from videodb ._upload import (
23
24
upload ,
29
30
class Connection (HttpClient ):
30
31
"""Connection class to interact with the VideoDB"""
31
32
32
- def __init__ (self , api_key : str , base_url : str ) -> "Connection" :
33
+ def __init__ (self , api_key : str , base_url : str , ** kwargs ) -> "Connection" :
33
34
"""Initializes a new instance of the Connection class with specified API credentials.
34
35
35
36
Note: Users should not initialize this class directly.
@@ -44,7 +45,9 @@ def __init__(self, api_key: str, base_url: str) -> "Connection":
44
45
self .api_key = api_key
45
46
self .base_url = base_url
46
47
self .collection_id = "default"
47
- super ().__init__ (api_key = api_key , base_url = base_url , version = __version__ )
48
+ super ().__init__ (
49
+ api_key = api_key , base_url = base_url , version = __version__ , ** kwargs
50
+ )
48
51
49
52
def get_collection (self , collection_id : Optional [str ] = "default" ) -> Collection :
50
53
"""Get a collection object by its ID.
@@ -256,32 +259,35 @@ def get_transcode_details(self, job_id: str) -> dict:
256
259
257
260
def upload (
258
261
self ,
259
- file_path : str = None ,
260
- url : str = None ,
262
+ source : Optional [str ] = None ,
261
263
media_type : Optional [str ] = None ,
262
264
name : Optional [str ] = None ,
263
265
description : Optional [str ] = None ,
264
266
callback_url : Optional [str ] = None ,
267
+ file_path : Optional [str ] = None ,
268
+ url : Optional [str ] = None ,
265
269
) -> Union [Video , Audio , Image , None ]:
266
270
"""Upload a file.
267
271
268
- :param str file_path: Path to the file to upload (optional)
269
- :param str url: URL of the file to upload (optional)
272
+ :param str source: Local path or URL of the file to upload (optional)
270
273
:param MediaType media_type: MediaType object (optional)
271
274
:param str name: Name of the file (optional)
272
275
:param str description: Description of the file (optional)
273
276
:param str callback_url: URL to receive the callback (optional)
277
+ :param str file_path: Path to the file to upload (optional)
278
+ :param str url: URL of the file to upload (optional)
274
279
:return: :class:`Video <Video>`, or :class:`Audio <Audio>`, or :class:`Image <Image>` object
275
280
:rtype: Union[ :class:`videodb.video.Video`, :class:`videodb.audio.Audio`, :class:`videodb.image.Image`]
276
281
"""
277
282
upload_data = upload (
278
283
self ,
279
- file_path ,
280
- url ,
281
- media_type ,
282
- name ,
283
- description ,
284
- callback_url ,
284
+ source ,
285
+ media_type = media_type ,
286
+ name = name ,
287
+ description = description ,
288
+ callback_url = callback_url ,
289
+ file_path = file_path ,
290
+ url = url ,
285
291
)
286
292
media_id = upload_data .get ("id" , "" )
287
293
if media_id .startswith ("m-" ):
@@ -290,3 +296,54 @@ def upload(
290
296
return Audio (self , ** upload_data )
291
297
elif media_id .startswith ("img-" ):
292
298
return Image (self , ** upload_data )
299
+
300
+ def record_meeting (
301
+ self ,
302
+ meeting_url : str ,
303
+ bot_name : str = None ,
304
+ bot_image_url : str = None ,
305
+ meeting_title : str = None ,
306
+ callback_url : str = None ,
307
+ callback_data : Optional [dict ] = None ,
308
+ time_zone : str = "UTC" ,
309
+ ) -> Meeting :
310
+ """Record a meeting and upload it to the default collection.
311
+
312
+ :param str meeting_url: Meeting url
313
+ :param str bot_name: Name of the recorder bot
314
+ :param str bot_image_url: URL of the recorder bot image
315
+ :param str meeting_title: Name of the meeting
316
+ :param str callback_url: URL to receive callback once recording is done
317
+ :param dict callback_data: Data to be sent in the callback (optional)
318
+ :param str time_zone: Time zone for the meeting (default ``UTC``)
319
+ :return: :class:`Meeting <Meeting>` object representing the recording bot
320
+ :rtype: :class:`videodb.meeting.Meeting`
321
+ """
322
+ if callback_data is None :
323
+ callback_data = {}
324
+
325
+ response = self .post (
326
+ path = f"{ ApiPath .collection } /default/{ ApiPath .meeting } /{ ApiPath .record } " ,
327
+ data = {
328
+ "meeting_url" : meeting_url ,
329
+ "bot_name" : bot_name ,
330
+ "bot_image_url" : bot_image_url ,
331
+ "meeting_title" : meeting_title ,
332
+ "callback_url" : callback_url ,
333
+ "callback_data" : callback_data ,
334
+ "time_zone" : time_zone ,
335
+ },
336
+ )
337
+ meeting_id = response .get ("meeting_id" )
338
+ return Meeting (self , id = meeting_id , collection_id = "default" , ** response )
339
+
340
+ def get_meeting (self , meeting_id : str ) -> Meeting :
341
+ """Get a meeting by its ID.
342
+
343
+ :param str meeting_id: ID of the meeting
344
+ :return: :class:`Meeting <Meeting>` object
345
+ :rtype: :class:`videodb.meeting.Meeting`
346
+ """
347
+ meeting = Meeting (self , id = meeting_id , collection_id = "default" )
348
+ meeting .refresh ()
349
+ return meeting
0 commit comments