Skip to content

Instantly share code, notes, and snippets.

@simonseo
Created July 31, 2023 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonseo/188862330645bb2a4e8cd0e4cbe69e38 to your computer and use it in GitHub Desktop.
Save simonseo/188862330645bb2a4e8cd0e4cbe69e38 to your computer and use it in GitHub Desktop.
Kakao calendar birthdays to iCal/ics
# events.json https://calendar.kakao.com/web/events?from=20230625T000000Z&to=20240624T235959Z&birthday=true&referer=month
# friends.json https://calendar.kakao.com/web/talk/friends
cal_template = """BEGIN:VCALENDAR
PRODID:-//Talk Calendar//iCal4j 2.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
X-WR-CALNAME:
{}
END:VCALENDAR
"""
birthday_template = """BEGIN:VEVENT
DTSTAMP:20230801T000000Z
DTSTART;VALUE=DATE:{dtstart}
DTEND;VALUE=DATE:{dtend}
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1
SUMMARY:{friend_name} 생일
UID:{uid}@kakao.com
END:VEVENT
"""
id_to_name = {}
for friend in friends:
id_to_name[friend['talkUserId']] = friend['name']
vevents = [
birthday_template.format(dtstart=e['startAt'][:8],
dtend=e['endAt'][:8],
friend_name=id_to_name[e['talkUserId']],
uid=e['talkUserId']
)
for e in events if e.get('type', '')=='BIRTHDAY'
]
with open('birthdays.ics', 'w') as f:
f.write(cal_template.format(''.join(vevents)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment