added calendars for kisfenyo
This commit is contained in:
@@ -1100,15 +1100,17 @@ data:
|
||||
@APP.get("/calendar/events")
|
||||
def calendar_events_api(
|
||||
count: int = Query(default=5, ge=1, le=50, description="Number of events to return"),
|
||||
days: int = Query(default=30, ge=1, le=365, description="Days to look ahead")
|
||||
days: int = Query(default=30, ge=1, le=365, description="Days to look ahead"),
|
||||
calendars: str = Query(default="", description="Comma-separated list of calendar names to include (empty = all)")
|
||||
):
|
||||
"""
|
||||
Returns upcoming calendar events from configured iCal feeds.
|
||||
Merges multiple calendars and sorts by start time.
|
||||
Use 'calendars' parameter to filter specific calendars (e.g., calendars=Családi,Órák)
|
||||
"""
|
||||
calendars = _parse_ical_urls()
|
||||
all_calendars = _parse_ical_urls()
|
||||
|
||||
if not calendars:
|
||||
if not all_calendars:
|
||||
return Response(
|
||||
content=json.dumps({
|
||||
"error": "No calendars configured",
|
||||
@@ -1119,10 +1121,17 @@ data:
|
||||
media_type="application/json; charset=utf-8"
|
||||
)
|
||||
|
||||
# Filter calendars if specified
|
||||
if calendars.strip():
|
||||
requested = [c.strip() for c in calendars.split(",") if c.strip()]
|
||||
filtered_calendars = {k: v for k, v in all_calendars.items() if k in requested}
|
||||
else:
|
||||
filtered_calendars = all_calendars
|
||||
|
||||
all_events = []
|
||||
calendar_status = {}
|
||||
|
||||
for name, url in calendars.items():
|
||||
for name, url in filtered_calendars.items():
|
||||
ical_text = _fetch_ical(url)
|
||||
if ical_text:
|
||||
events = _parse_ical_events(ical_text, name, days)
|
||||
|
||||
Reference in New Issue
Block a user