无法使用Python获取Google日历中的插件事件

问题描述 投票:0回答:0

在我的公司,我们现在从 Zoom 转向 Google Meet,我为用户创建了一个自动化功能,从即将到来的日历活动中删除所有 Zoom 会议信息,并将其替换为 Google Meet。

在大多数情况下,Zoom 会议信息显示在活动详细信息的位置和描述中,但我很少有使用 Zoom 插件安排的活动,我的问题是当我尝试使用 Python 获取 Google 日历中的插件活动时。我正在使用以下代码:

我的自动化代码功能:

def process_event(service, event, email):
    print("Evaluating event: ", event)
    
    # Check if the event has a Zoom link in the description, the location, and if the event is not an all-day event
    if ('zoom.us' in event.get('description', '') 
        or 'zoom.us' in event.get('location', '') 
        and 'dateTime' in event['start']):
        print("Updating event: ", event)
        # Update the event description and location to remove Zoom link
        event['description'] = re.sub(r'http[s]?://mycompany\.zoom\.us/[^\s]*', '', event.get('description', ''))
        event['location'] = re.sub(r'http[s]?://mycompany\.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}'

谢谢!

我试图通过将其添加到

if
语句中来获取插件事件,但仍然无法在响应中获取这些插件会议:

or 'addOn' in event.get('conferenceData', {}).get('conferenceSolution', {}).get('key', {}).get('type', '')
python google-calendar-api
© www.soinside.com 2019 - 2024. All rights reserved.