What’s for lunch?

One thing that’s nice to know when you’re a student, is what’s for lunch at the university restaurant.

In that regard, I looked for a way to easily generate an iCal of the week’s menu. First step: scour the CROUS Grenoble website in search of the menu, because I know it’s there somewhere.

Turns out, they have the menu for the current week in .png, .pdf and an RSS feed. They also have the one for the following week, but not in RSS.

So, I started to think about how I could automate the process, and considering that BASH might not be the best for this and that I wouldn’t go about scripting in PHP, I decided to take a shot at Python.

Second step: learn some Python, analyse the RSS feed structure and get this working.

The way I’ve basically done it, is to import and parse the RSS feed, then since each item in the feed corresponds to one service (day, lunch/dinner) it’s only a matter of creating a calendar event for each one (with first parsing the date, day and service). I filter out Friday evening, and both Saturday and Sunday, since there’s never any service then. Thursday evening seems to always be at the other restaurant, but I’m not sure.

Overall, it took a small afternoon to get it all worked out, it was quite fun to work on a little project like this. I guess as long as they don’t change the structure of their feed then it should all work fine. Because the feed seems to update at 00:00 on Mondays, I’ve also set-up a cron script to check it a few times around then, and once we’ve got the new one it’ll send it to stic.imnotacyb.org/menuRU.ics. I’ve also learned a bit of how to use Git and GitHub, so the repository for this project can be found here: github.com/JohannDickson/UDS_menuRU.

This entry was posted in Software, University, WebDev and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *