Skip to content
Snippets Groups Projects
Commit afe971bc authored by Martin Mareš's avatar Martin Mareš
Browse files

Recurring meetings done right (hopefully)

parent f8ab6ddb
No related branches found
No related tags found
No related merge requests found
...@@ -7,8 +7,9 @@ CREATE TABLE zoom_users ( ...@@ -7,8 +7,9 @@ CREATE TABLE zoom_users (
CREATE TABLE zoom_meetings ( CREATE TABLE zoom_meetings (
id serial PRIMARY KEY, -- our internal id serial PRIMARY KEY, -- our internal
meeting_id int NOT NULL, -- Zoom's meeting ID (not unique for recurring meetings!) meeting_id int NOT NULL, -- Zoom's meeting ID
uuid varchar(255) NOT NULL, -- Zoom's uuid varchar(255) NOT NULL, -- Zoom's meeting instance ID
occurrence_id bigint DEFAULT NULL, -- Occurrence for recurring meetings
host_id int NOT NULL REFERENCES zoom_users(id), host_id int NOT NULL REFERENCES zoom_users(id),
topic varchar(255) DEFAULT '', topic varchar(255) DEFAULT '',
type int NOT NULL, -- 1=instant, 2=scheduled, 3=recurring no time, 8=recurring fixed time type int NOT NULL, -- 1=instant, 2=scheduled, 3=recurring no time, 8=recurring fixed time
......
...@@ -9,9 +9,10 @@ import psycopg2.extras ...@@ -9,9 +9,10 @@ import psycopg2.extras
import time import time
import dateutil.parser import dateutil.parser
# import dateutil.tz # import dateutil.tz
import sys
verbose = True verbose = True
very_verbose = False very_verbose = True
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('zoom.ini') config.read('zoom.ini')
...@@ -29,11 +30,42 @@ def parse_time(iso_time, tz_name): ...@@ -29,11 +30,42 @@ def parse_time(iso_time, tz_name):
return utc return utc
def add_recurring(uid, meet):
time.sleep(0.2)
resp = client.meeting.get(host_id = meet['host_id'], id = meet['id'])
resp.raise_for_status()
details = json.loads(resp.content)
if very_verbose:
pprint(details)
for occ in details["occurrences"]:
db.execute("""
INSERT INTO zoom_meetings
(meeting_id, uuid, occurrence_id, host_id, topic, type, start_time, duration)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
""", (
meet['id'],
meet['uuid'],
occ['occurrence_id'],
uid,
meet['topic'],
meet['type'],
parse_time(occ['start_time'], meet['timezone']),
occ['duration'],
))
def add_meeting(uid, meet): def add_meeting(uid, meet):
if 'start_time' not in meet: type = meet['type']
if type == 3:
# Type 3 meetings (scheduled with no time) are ignored # Type 3 meetings (scheduled with no time) are ignored
return return
if type == 8:
# Recurring meetings: need to ask for the list of occurrences
add_recurring(uid, meet)
return
db.execute(""" db.execute("""
INSERT INTO zoom_meetings INSERT INTO zoom_meetings
(meeting_id, uuid, host_id, topic, type, start_time, duration) (meeting_id, uuid, host_id, topic, type, start_time, duration)
...@@ -59,7 +91,7 @@ def get_meetings(uid, user_id): ...@@ -59,7 +91,7 @@ def get_meetings(uid, user_id):
if verbose: if verbose:
print(f"Fetching meetings for user {user_id}: page {page_id} of {num_pages}") print(f"Fetching meetings for user {user_id}: page {page_id} of {num_pages}")
resp = client.meeting.list(user_id = user_id, type = 'upcoming', page_number = page_id) resp = client.meeting.list(user_id = user_id, type = 'scheduled', page_number = page_id)
resp.raise_for_status() resp.raise_for_status()
meeting_list = json.loads(resp.content) meeting_list = json.loads(resp.content)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment