Sabbah13 commited on
Commit
b529ea9
·
verified ·
1 Parent(s): 8f2caf4

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +62 -0
main.py CHANGED
@@ -313,3 +313,65 @@ async def download_video(request: Request, token: str = Depends(verify_token)):
313
  except Exception as e:
314
  logger.error(f"Error while processing the request: {str(e)}")
315
  return {"status": "error", "message": str(e)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  except Exception as e:
314
  logger.error(f"Error while processing the request: {str(e)}")
315
  return {"status": "error", "message": str(e)}
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+ class MeetingEvent(BaseModel):
325
+ meeting_url: str,
326
+ meeting_date: str
327
+
328
+ class MeetingDeleteEvent(BaseModel):
329
+ bot_id: str,
330
+
331
+
332
+ # Подключение бота к отложенному созвону
333
+ @app.post("/connect_bot/event/")
334
+ async def connect_bot(meeting_data: MeetingEvent, token: str = Depends(verify_token)):
335
+ meeting_url = meeting_data.meeting_url
336
+ meeting_date = meeting_data.meeting_date
337
+ logger.info(f"Connect bot to the meeting at: {meeting_url} in {meeting_date}")
338
+
339
+ headers = {
340
+ "Authorization": recall_authorization_token,
341
+ "accept": "application/json",
342
+ "content-type": "application/json"
343
+ }
344
+ data = {
345
+ "meeting_url": meeting_url,
346
+ "bot_name": "Aspirity Notetaker"
347
+ "transcription_options": { "provider": "meeting_captions" },
348
+ "join_at": meeting_date
349
+ }
350
+
351
+ response = requests.post(recall_url, headers=headers, json=data)
352
+
353
+ if response.status_code == 201:
354
+ response_json = response.json()
355
+ bot_id = response_json.get('id')
356
+ logger.info(f"Bot connected to the meeting at: {meeting_url}. Bot ID: {bot_id}. Meeting_date: {meeting_date}")
357
+ return {"status": "Bot connected", "meeting_url": meeting_url, "Bot ID": bot_id}
358
+ else:
359
+ logger.info(f"Request failed with status code {response.status_code}. Meeting_url: {meeting_url}")
360
+ return {"status": "Error", "meeting_url": meeting_url}
361
+
362
+
363
+ # Отключение бота от отложенного созвона
364
+ @app.post("/delete_bot/event/")
365
+ async def connect_bot(meeting_data: MeetingDeleteEvent, token: str = Depends(verify_token)):
366
+ bot_id = meeting_data.bot_id
367
+ logger.info(f"Now delete bot with id: {bot_id}")
368
+ response = requests.delete(recall_url, headers=headersRetrieve).json()
369
+
370
+ if response.status_code == 201:
371
+ response_json = response.json()
372
+ bot_id = response_json.get('id')
373
+ logger.info(f"Bot connected to the meeting at: {meeting_url}. Bot ID: {bot_id}")
374
+ return {"status": "Bot connected", "meeting_url": meeting_url, "Bot ID": bot_id}
375
+ else:
376
+ logger.info(f"Request failed with status code {response.status_code}. Meeting_url: {meeting_url}")
377
+ return {"status": "Error", "meeting_url": meeting_url}