Auto-sync: 2026-02-13 13:24:12
This commit is contained in:
57
skills/macos-calendar/fetch_events.scpt
Normal file
57
skills/macos-calendar/fetch_events.scpt
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/osascript
|
||||
on run argv
|
||||
set daysToFetch to 7
|
||||
if (count of argv) > 0 then
|
||||
set daysToFetch to (item 1 of argv) as integer
|
||||
end if
|
||||
|
||||
set currentDate to current date
|
||||
set endDate to currentDate + (daysToFetch * days)
|
||||
|
||||
tell application "Calendar"
|
||||
set output to ""
|
||||
set allCalendars to calendars
|
||||
|
||||
repeat with aCal in allCalendars
|
||||
set calName to name of aCal
|
||||
-- Filter out holidays or subscription calendars if they are too noisy, but for now keep all.
|
||||
|
||||
set calEvents to (every event of aCal whose start date is greater than or equal to currentDate and start date is less than or equal to endDate)
|
||||
|
||||
repeat with anEvent in calEvents
|
||||
try
|
||||
set evtSummary to summary of anEvent
|
||||
on error
|
||||
set evtSummary to "No Title"
|
||||
end try
|
||||
|
||||
try
|
||||
set evtStart to start date of anEvent
|
||||
on error
|
||||
set evtStart to "Unknown"
|
||||
end try
|
||||
|
||||
try
|
||||
set evtEnd to end date of anEvent
|
||||
on error
|
||||
set evtEnd to "Unknown"
|
||||
end try
|
||||
|
||||
try
|
||||
set evtLoc to location of anEvent
|
||||
if evtLoc is missing value then set evtLoc to ""
|
||||
on error
|
||||
set evtLoc to ""
|
||||
end try
|
||||
|
||||
set output to output & "Calendar: " & calName & "\nEvent: " & evtSummary & "\nStart: " & evtStart & "\nEnd: " & evtEnd & "\nLocation: " & evtLoc & "\n---\n"
|
||||
end repeat
|
||||
end repeat
|
||||
|
||||
if output is "" then
|
||||
return "No events found for the next " & daysToFetch & " days."
|
||||
else
|
||||
return output
|
||||
end if
|
||||
end tell
|
||||
end run
|
||||
Reference in New Issue
Block a user