18 lines
438 B
Python
18 lines
438 B
Python
from ics import Calendar
|
|
import requests
|
|
import logger
|
|
|
|
def grab_calendar(ics_url: str) -> Calendar | None:
|
|
response = requests.get(ics_url)
|
|
|
|
if response.status_code != 200:
|
|
logger.warning("Unable to fetch calendar")
|
|
return None
|
|
|
|
try:
|
|
calendar = Calendar(response.content.decode("utf-8"))
|
|
except Exception:
|
|
logger.warning("Unable to parse calendar")
|
|
return None
|
|
|
|
return calendar |