fully implemented project
This commit is contained in:
18
app/grabber.py
Normal file
18
app/grabber.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from ics import Calendar
|
||||
import requests
|
||||
import logger
|
||||
|
||||
def grab_calendar(ics_url: str):
|
||||
response = requests.get(ics_url)
|
||||
|
||||
if response.status_code != 200:
|
||||
logger.warning("Unable to fetch calendar")
|
||||
return None
|
||||
|
||||
try:
|
||||
calendar = Calendar(response.text)
|
||||
except Exception:
|
||||
logger.warning("Unable to parse calendar")
|
||||
return None
|
||||
|
||||
return calendar
|
||||
Reference in New Issue
Block a user