在我的公司,我们现在正在从 Zoom 转向 Google Meet,我为用户创建了一个自动化系统,将所有 Zoom 会议转换为 Meet。
以正常方式安排 Zoom 会议时,这很容易做到(我在描述或位置字段中搜索 Zoom,然后替换它)。
但是,如果 Zoom 会议是使用 Zoom 插件创建的,那么我无法使用 Google Calendar API 找到它。 尽管使用视频会议链接创建事件,conferenceData 字段确实出现在 API 响应中,但我无法使用它们来过滤这些会议。
我的自动化代码功能:
def process_event(service, event, email):
print("Evaluating event: ", event)
# Print conferenceData for debugging
print("Conference Data: ", event.get('conferenceData'))
# Check if the event has a Zoom link in the description, the location,
# or the event has conferenceData with a conferenceId
# and if the event is not an all-day event
try:
if ('zoom.us' in event.get('description', '')
or 'zoom.us' in event.get('location', '')
or 'addOn' in event.get('conferenceData', {}).get('conferenceSolution', {}).get('key', {}).get('type', '')
) and 'dateTime' in event['start']:
print("Updating event: ", event)
# Update the event description and location to remove Zoom link
# This uses a regular expression to remove any URLs that include 'zoom.us'
event['description'] = re.sub(r'http[s]?://wix\.zoom\.us/[^\s]*', '', event.get('description', ''))
event['location'] = re.sub(r'http[s]?://wix\.zoom\.us/[^\s]*', '', event.get('location', ''))
# Update the event to add Google Meet
event['conferenceData'] = {
'createRequest': {
'requestId': str(uuid.uuid4()), # generates a unique identifier
'conferenceSolutionKey': {
'type': 'hangoutsMeet'
}
}
}
# Update the event on Google Calendar
try:
updated_event = service.events().update(calendarId=email, eventId=event['id'], body=event,
conferenceDataVersion=1).execute()
updated_event_message = 'Updated event: ' + updated_event.get('summary', '')
print(updated_event_message)
return updated_event_message
except Exception as e:
print(f'Error updating event: {e}')
return f'Error updating event: {e}'
else:
return "Event does not meet conditions for updating." # Return default message when event does not need updating
except Exception as e:
print("Exception while processing event: ", e)
return f"Exception while processing event: {e}" # Return message when exception occurs
谢谢!
我试图使用conferenceData响应来获取这些数据,但没有成功。