Update app.py
parent
2b579870e2
commit
9d84a308a5
16
app.py
16
app.py
|
@ -3,7 +3,8 @@ import json
|
||||||
import requests
|
import requests
|
||||||
import tzdata
|
import tzdata
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from loguru import logger
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from zoneinfo import ZoneInfo
|
from zoneinfo import ZoneInfo
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
@ -53,7 +54,7 @@ def create_calendar_events_from_json(caldav_url, calendar_name, username, passwo
|
||||||
#print(f"Remaining duplicates: {len(remaining)}")
|
#print(f"Remaining duplicates: {len(remaining)}")
|
||||||
|
|
||||||
# 4. Create events from JSON data
|
# 4. Create events from JSON data
|
||||||
print(f"Updating calendar...")
|
logger.info("Updating calendar...")
|
||||||
ical_data_event = f"""BEGIN:VCALENDAR
|
ical_data_event = f"""BEGIN:VCALENDAR
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
|
@ -66,7 +67,7 @@ CATEGORIES:RetroAchievements
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
"""
|
"""
|
||||||
print(f"Updating reminders...")
|
logger.info("Updating todos...")
|
||||||
ical_data_todo = f"""BEGIN:VCALENDAR
|
ical_data_todo = f"""BEGIN:VCALENDAR
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
|
@ -82,19 +83,20 @@ END:VCALENDAR
|
||||||
"""
|
"""
|
||||||
|
|
||||||
my_calendar.save_event(ical_data_event)
|
my_calendar.save_event(ical_data_event)
|
||||||
print(f"Calendar was updated.")
|
logger.info("Calendar updated.")
|
||||||
|
|
||||||
my_calendar.save_todo(ical_data_todo)
|
my_calendar.save_todo(ical_data_todo)
|
||||||
print(f"Reminders were updated.")
|
logger.info("Calendar updated.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error: {str(e)}")
|
logger.exception{"Error: {str(e)}"}
|
||||||
|
|
||||||
# Usage example
|
# Usage example
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
logger.add("output.log", backtrace=True, diagnose=True)
|
||||||
|
|
||||||
if len(sys.argv) != 7:
|
if len(sys.argv) != 7:
|
||||||
print("Usage: python3 app.py <caldav_url> <calendar_name> <username> <password> <ra_api_key> [OPTIONAL] <ra_username>")
|
logger.exception{"Usage: python3 app.py <caldav_url> <calendar_name> <username> <password> <ra_api_key> [OPTIONAL] <ra_username>"}
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
CALDAV_URL = sys.argv[1]
|
CALDAV_URL = sys.argv[1]
|
||||||
|
|
Loading…
Reference in New Issue