So I have spent the last few nights with a small Pet Project: A script that automatically collects and stores game prices from Steam, and also notifies me when there is a discount. This usually would be a fairly easy task, there were just a few things which required special attention:
- I want to store the prices for later reference
- I want to share this script with my friends on the long term (or rather, the configuration interface)
- I want it to be easily configurable
- I want to run it even when my computer is turned off
Obviously I need a cloud solution for this. The first three that pops into my mind are AWS, GAE or Azure, but I picked none of these; from the first moment I knew what there right tool will be.
Enter Google Sites.
Google Sites is the perfect tool when you need a place to dump some content that is accessible on the Internet, and you need something more than a blog. For fairly simple pages with announcements, lists, file uploads, etc. it is perfect. Also, there is a hidden gem: It can include Google Apps Scripts, which can be used for several different things, including scheduled execution.
So, the next thing to decide about is the approach. The Steam API is - sadly - insufficient for this, so I had to somehow use the Steam webpage. Which means that it will be messy. I can access the store page in several different ways:
- I can grab the list of discounted items, and check for each game in it
- I can go the the product page and get the price from there
- I can do a search for the games one by one, and find the one result that is the game itself, and get the price from that line
The first one would be fairly easy if not for two things: I need the price even if the game is not discounted, and the page is paginated, so I'd need to load all of those pages, compile the whole list from them, and then do the lookup.
So I had a go with the second approach. I easily got to the point of fetching the game page content - it can be done with ids instead of names, which makes it a much more precise operation - but then I hit another wall. Namely, the age check. Because of the age restricted material in some videos and screenshots, steam will ask you to state your age when entering those pages. It's not extremely hard to simulate this with the script, but messy. I decided to check the third option instead, whether it is simpler.
Last night was mainly spent on this task. Just before midnight, when I thought that it is finally done, I ran into a very strange bug. Spent a lot of time tracking it down, and at about half past midnight I realized that this is probably something to do with the way the xml parsing works. (So not an actual bug in my code, rather some optimization in the xml framework).
I think I have a solution for it, but I can't tell that before actually trying it. If it is working, I am basically there, this is the last piece of code that is needed to be finished for having a working, if somewhat simplified, version.