Home

Awesome

ETH Lecture Bot

Uses RSS feed to send updates via Telegram chatbot when lectures have been uploaded. Try it out for yourself here (you need Telegram). Only videos which are hosted on the ETH video portal are tracked.

Scripts

bot.py: Runs the chatbot

course.py: For the course class

parse_courses.py: Reads the courses for a given semester, find which have an RSS feed, pickles results

update_coures.py: Reads RSS feeds to check when a course has been updated

Usage

For each new semester, the parse courses script should be ran. This requires the entire course catalogue (the pdf found here, not the course data file). Further instructions can be found in the script itself. The parameters (below imports) are important; the year (YYYY) and season (autumn/spring) must be set. If the pdf should be parsed (if you haven't already) READ_PDF should be set to True, should the courses be filtered out for which an RSS feed does not exist FIND_HITS should be set to True as well. The full list of courses is saved in the all_courses.pkl, and only the courses with RSS feeds are saved in the rss_courses.pkl. The rss_courses.pkl pickle is a dictionary with the departments as keys corresponding to a list of Course objects.

The update_courses.py script should be run at whatever interval is desired. Runtime is the only limiting factor. Script imports all of the admissable courses (those with an RSS feed), then it goes and checks if there is a newer entry in the RSS feed. If there is it updates the lastest item in the respective course class, and sets has_been_updated to True. After updating, it checks to make sure that it isn't overwriting any changes to the subscribers by importing the latest version of the courses (could have been updated during runtime), it then merges any changes (updates subscribers as well as latest item), and then sends this updated and merged list of courses back to a pickle.

bot.py should be run constantly (or whenever you want the bot to work). Very simply interface, the user can either sub to a lecture, or unsub from one they have already subbed to. It is important that when subbing/unsubbing, not only are the user's subscriptions updated, but the course's subscribers as well. When these are changed, the pickle is updated. At a regular time interval the courses are looked through to see if any of them have the has_been_updated value been set to True in which case, a message is sent to all of the subscribers of that course with the latest lecture information, and this value is then set to False. After checking all courses, the pickle is updated.

The notifications are sent out by restarting the bot every 15 minutes (cron job), the updater is called 4 minutes before each bot restart. The bot is currently hosted on my home server.

TODO