forked from Olen/Spond
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ical.py
35 lines (28 loc) · 965 Bytes
/
ical.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import asyncio
import spond
from ics import Calendar, Event
from config import username, password
ics_file = 'spond.ics'
async def main():
s = spond.Spond(username=username, password=password)
c = Calendar()
events = await s.getEvents()
for event in events:
e = Event()
e.uid = event['id']
e.name = event['heading']
if 'description' in event:
e.description = event['description']
e.begin = event['startTimestamp']
e.end = event['endTimestamp']
if 'location' in event:
e.location = "{}, {}".format(event['location']['feature'], event['location']['address'])
c.events.add(e)
if not os.path.exists('./exports'):
os.makedirs('./exports')
with open(os.path.join("./exports", ics_file), 'w') as out_file:
out_file.writelines(c)
await s.clientsession.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())