Add basic calendar scraping
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user