forked from jazzband/icalevents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (30 loc) · 996 Bytes
/
main.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
35
36
37
38
39
40
41
from icalevents.icalevents import events_async, latest_events, all_done
from time import sleep
if __name__ == "__main__":
keys = []
with open("calendars.txt", mode="r", encoding="utf-8") as f:
counter = 1
while True:
line = f.readline()
if not line:
break
name, url = line.split(maxsplit=1)
name = name.strip()
url = url.strip()
fix_apple = False
if name == "icloud":
fix_apple = True
key = "req_%d" % counter
counter += 1
keys.append(key)
events_async(key, url, fix_apple=fix_apple)
while keys:
print("%d request running." % len(keys))
for k in keys[:]:
if all_done(k):
print("Request %s finished." % k)
keys.remove(k)
es = latest_events(k)
for e in es:
print(e)
sleep(2)