Skip to content

Instantly share code, notes, and snippets.

@wernersa
Created April 30, 2023 08:51
Show Gist options
  • Save wernersa/53d61af74bab54e903c5aa59b2836f63 to your computer and use it in GitHub Desktop.
Save wernersa/53d61af74bab54e903c5aa59b2836f63 to your computer and use it in GitHub Desktop.
Get the 2023 IFSC events in JSON-format and export as iCal format
import json
from urllib.request import urlopen
import ics
from dateutil import parser
if __name__ == "__main__":
url = "https://components.ifsc-climbing.org/results-api.php?api=season_leagues_calendar&league=418"
response = urlopen(url)
data = json.load(response)
c = ics.Calendar()
for item in data["events"]:
print(item["event"].encode("utf-8"))
e = ics.Event(
name=item["event"],
begin=parser.parse(item["starts_at"]),
end=parser.parse(item["ends_at"]),
)
print(e)
c.events.add(e)
with open("my.ics", "w") as f:
f.writelines(c.serialize())
BEGIN:VCALENDAR
VERSION:2.0
PRODID:ics.py - http://git.io/lLljaA
BEGIN:VEVENT
DTEND:20230909T215900Z
DTSTART:20230907T220000Z
SUMMARY:IFSC - Climbing World Cup (L) - Koper (SLO) 2023
UID:eed9ef06-296e-4752-835c-c0736ba0d436@eed9.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230423T145900Z
DTSTART:20230420T150000Z
SUMMARY:IFSC - Climbing World Cup (B) - Hachioji (JPN) 2023
UID:de970c37-93e7-4118-a785-b1e06fb94608@de97.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230611T215900Z
DTSTART:20230608T220000Z
SUMMARY:IFSC - Climbing World Cup (B) - Brixen (ITA) 2023
UID:43bb2dd9-5850-4109-b017-5ec7b3e96e3d@43bb.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230812T215900Z
DTSTART:20230731T220000Z
SUMMARY:IFSC - Climbing World Championships (B\,L\,S\,B&L) - Bern (SUI) 2023
UID:fdcb0c97-4777-497a-bde6-b185a104db18@fdcb.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230430T145900Z
DTSTART:20230427T150000Z
SUMMARY:IFSC - Climbing World Cup (B\,S) - Seoul (KOR) 2023
UID:c6977361-0087-42c6-8d4d-fd80165fc23b@c697.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230715T215900Z
DTSTART:20230713T220000Z
SUMMARY:IFSC - Climbing World Cup (L) - Briançon (FRA) 2023
UID:8d2f7107-dfd1-4970-88a5-2d40a1ea4656@8d2f.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230604T215900Z
DTSTART:20230601T220000Z
SUMMARY:IFSC - Climbing World Cup (B) - Prague (CZE) 2023
UID:6b1e8269-535b-4503-aefe-550ce4152c85@6b1e.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230924T155900Z
DTSTART:20230921T160000Z
SUMMARY:IFSC - Climbing World Cup (L\,S) - Wujiang (CHN) 2023
UID:e77cbfec-65b5-4b64-9fb1-0cbcdbbb73ff@e77c.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230522T055900Z
DTSTART:20230519T060000Z
SUMMARY:IFSC - Climbing World Cup (B\,S) - Salt Lake City (USA) 2023
UID:280935bc-28f6-445f-9b5c-fc0d8db64193@2809.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230702T215900Z
DTSTART:20230629T220000Z
SUMMARY:IFSC - Climbing World Cup (L\,S) - Villars (SUI) 2023
UID:5f4f98f4-e73e-4f7c-94e9-1ab09e410e23@5f4f.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230507T165900Z
DTSTART:20230505T170000Z
SUMMARY:IFSC - Climbing World Cup (S) - Jakarta (INA) 2023
UID:17029af0-6db4-4b10-801d-8bb7a586c270@1702.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230618T215900Z
DTSTART:20230613T220000Z
SUMMARY:IFSC - Climbing World Cup (B\,L) - Innsbruck (AUT) 2023
UID:34138281-9a32-44a1-bcf9-61d379bb675c@3413.org
END:VEVENT
BEGIN:VEVENT
DTEND:20230709T215900Z
DTSTART:20230706T220000Z
SUMMARY:IFSC - Climbing World Cup (L\,S) - Chamonix (FRA) 2023
UID:00f87f64-146d-4f84-b6cc-d5ff3ea76590@00f8.org
END:VEVENT
END:VCALENDAR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment