mirror of
https://github.com/status-im/cabot.git
synced 2025-02-25 02:45:16 +00:00
24 lines
583 B
Python
24 lines
583 B
Python
|
|
||
|
from django.conf import settings
|
||
|
from icalendar import Calendar, Event
|
||
|
import requests
|
||
|
|
||
|
|
||
|
def get_calendar_data():
|
||
|
feed_url = settings.CALENDAR_ICAL_URL
|
||
|
resp = requests.get(feed_url)
|
||
|
cal = Calendar.from_ical(resp.content)
|
||
|
return cal
|
||
|
|
||
|
|
||
|
def get_events():
|
||
|
events = []
|
||
|
for component in get_calendar_data().walk():
|
||
|
if component.name == 'VEVENT':
|
||
|
events.append({
|
||
|
'start': component.decoded('dtstart'),
|
||
|
'end': component.decoded('dtend'),
|
||
|
'summary': component.decoded('summary'),
|
||
|
'uid': component.decoded('uid'),
|
||
|
})
|
||
|
return events
|