Add basic calendar scraping

This commit is contained in:
2023-10-01 17:58:37 +01:00
parent 915ce5112d
commit 83bc134998
4 changed files with 32 additions and 34 deletions
+20
View File
@@ -0,0 +1,20 @@
class CalendarScraperJob < ApplicationJob
queue_as :default
def perform(*args)
ics_file = HTTParty.get("https://mytimetable.bath.ac.uk/ical?6519757b&group=false&timetable=!MjAyMyFzdHVkZW50c2V0ITRDRjQ5MjlGRTg1M0Q4N0MyMDZENTVDNUQ3QTJFNzk0&eu=amMzMDkxQGJhdGguYWMudWs=&h=MiuDbRiudE_Yf7B25v2SfEuFCtmYGkFb5sAUI3yGmtY=")
calendars = Icalendar::Calendar.parse(ics_file)
calendar = calendars.first
calendar.events.each do |event|
summary = event.summary
match = summary.split('-')
# Handle odd events we don't care about
return if match.length != 2
unit_code = match[0]
short_lecture_title = match[1]
end
end
end