forked from NoLog.cz/trhlina-calendar
39 lines
1 KiB
Python
39 lines
1 KiB
Python
#from flask import Flask, render_template, request, redirect
|
|
from ics import Calendar, Event
|
|
import requests
|
|
from dotenv import load_dotenv
|
|
import os
|
|
import re
|
|
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
PUBLIC_ICAL_URL = os.getenv('PUBLIC_ICAL_URL')
|
|
PRIVATE_ICAL_URL = os.getenv('PRIVATE_ICAL_URL')
|
|
ical_headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8'}
|
|
|
|
public_cal_raw = requests.get(PUBLIC_ICAL_URL, headers=ical_headers).text
|
|
private_cal_raw = requests.get(PRIVATE_ICAL_URL, headers=ical_headers).text
|
|
|
|
# print(public_cal_raw)
|
|
|
|
pub_cal = Calendar(public_cal_raw)
|
|
priv_cal = Calendar(private_cal_raw)
|
|
|
|
final_cal = Calendar()
|
|
|
|
for event in priv_cal.events:
|
|
event.url = None
|
|
#event.uid = None
|
|
event.description = None
|
|
event.name = "Closed event - not for public"
|
|
final_cal.events.add(event)
|
|
|
|
for event in pub_cal.events:
|
|
event.url = None
|
|
event.description = event.description.split("\n",2)[2] # Remove forum URL from description
|
|
final_cal.events.add(event)
|
|
|
|
print(final_cal.serialize())
|