aboutsummaryrefslogtreecommitdiff
path: root/fetch-ics
blob: 0b06ddac3f038d6b956ef887d0543a33721c92df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python3
import os
import sys
import requests

for slug in sys.argv[1:]:
    id_path = os.path.join("events", slug, "id")
    id = open(id_path, "r").read()
    ics_path = os.path.join("events", slug, "ics")
    if os.path.exists(ics_path):
        continue
    ics_url = f"http://www.portugalrunning.com/export-events/{id}_0/"
    response = requests.get(ics_url)
    response.raise_for_status()
    with open(ics_path, "wb") as f:
        f.write(response.content)