#!/bin/sh

#set -e

# Generate HTML fragment usable on the NUUG front page for the list
# of events.  The final result need some editing to correct the
# location information.

fetch_ical_file() {
    url="$1"
    file="$2"
    # Fake being firefox, as www.meetup.com reject libwww-perl/GET
    #GET -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0" "$url" > "$file"
    wget --quiet --user-agent "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0" "$url" -O "$file"
    files="$files $file"
}
# Hackeriet, updated 2020-08-12
fetch_ical_file "https://www.meetup.com/hackeriet/events/ical/" hackeriet.ics

# Usenix Conferences, updated 2023-03-24
fetch_ical_file 'https://www.google.com/calendar/ical/usenix.org_ucqd5fh7edtegh6mtuusmi81a0@group.calendar.google.com/public/basic.ics' usenix.ics

# Bergen Linux User Group, updated 2020-08-12
fetch_ical_file "https://www.meetup.com/bergen-linux-and-bsd-user-group/events/ical/" blug.ics

fetch_ical_file 'https://www.google.com/calendar/ical/g2oiqnvjrh6av433j5h169h8u0%40group.calendar.google.com/public/basic.ics' holderdeord.ics
fetch_ical_file 'https://www.meetup.com/bitraf/events/ical/Bitraf' bitraf.ics

# Debconf 23, added 2022-09-08
fetch_ical_file 'https://debconf23.debconf.org/schedule/schedule.ics' debconf23.ics

$(dirname $0)/ical2html $files

rm $files
