Skip to content

Instantly share code, notes, and snippets.

@prail
Created July 27, 2024 17:15
Show Gist options
  • Save prail/e03e78e883898290ad3e2b70383e59e2 to your computer and use it in GitHub Desktop.
Save prail/e03e78e883898290ad3e2b70383e59e2 to your computer and use it in GitHub Desktop.
Eagles Nest Class Calendar Filter/Generator
# ICS file filter
BEGIN {
FS = ":"
buffer = ""
notevent = 0
}
($1~/^BEGIN/ && $2~/VEVENT/) {
keep = 1;
}
($1~/^BEGIN/ && $2!~/VEVENT/) {
notevent = 1;
}
$1~/SUMMARY/ && notevent==0 {
if ($2~/[A-Z]{2} [0-9]{3}.+[0-9]+.*/)
{
keep = 1;
}
else
{
# clear the event buffer and inform not to keep whole record
buffer = "";
keep = 0;
}
}
notevent==0 {
if (keep==1)
{
buffer=buffer$0"\n"
}
}
($1~/^END/ && $2~/VEVENT/) {
if (keep == 1)
{
printf("%s", buffer);
buffer = "";
keep = 0;
}
}
($1~/^END/ && $2!~/VEVENT/) {
notevent = 0;
print $0;
}
notevent==1 { print $0 }
#!/bin/bash
CALENDAR_URL="put_your_eagles_nest_calendar_url_here"
wget -q -O - "${CALENDAR_URL/webcal/http}" | awk -f ./class_filter.awk > class_calendar.ics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment