May 22, 2017 · Practical Automation

Practical Automation: Cinema listings to my inbox

This post is part of an occasional series on the subject of "Practical Automation": small pieces of scripting/tooling which can ease the burden of mundane or repetitive everyday tasks. My previous post on Creating my first Slack bot was somehow a year ago; expect the posts to appear much more frequently in the coming months!

There's no avoiding the subject - I'm certainly something of a movie addict. The clues are certainly out there: my film podcast Screen Testing is marching towards double-figures, and at the time of writing, I've seen 293 films this year including 53 visits to the cinema.

Because of this, I spend a lot of time browsing the upcoming movie listings on the Cineworld website (I'm a Cineworld Unlimited subscriber, which means I get to see as many films as I like for a single monthly fee - ergo I'll watch pretty much anything that comes out.)

There are a few minor recurring gripes with this process:

  • My local cinema (St Neots) is quite small, so it has a fairly limited selection to choose from. My next nearest (Huntingdon) has a few more, but I'll still often have to look further afield (Stevenage or Milton Keynes) for specific films which are on limited release.
  • Each cinema releases its next week's showtimes according to its own unpredictable schedule. Listings are usually online at some point on Monday or Tuesday, unless there's a bank holiday which can push them back to Wednesday occasionally.
  • For certain screenings, it's vital to find out about the new listings as early as possible. For instance, if it's a 3D screening, there's a benefit to being able to book a central seat, or if I'm going with friends then there's a rush to find 3-4 seats together.

This meant that I was wasting a fair amount of time on Mondays/Tuesdays checking the listings pages for multiple cinemas to see whether tickets had become available yet. Using my favourite xkcd reference for automation, I figured that I could easily justify spending a few hours trying to automate a solution to the problem. And lo, that's what I did!

Emailed cinema listings

Click here to see the Cineworld Listings Watcher project on GitHub

There's a lot more detail (including the source code that you can play with yourself) on the GitHub link, but this was quite a simple solution to solve:

  • I discovered that the data on Cineworld's website is all loaded through API endpoints with predictable formatting (e.g. requesting data by cinema ID and by date).
  • I learned about the service which sits in the cloud and can be scheduled to run scripts on a repeating schedule.
  • I mused over what would be an appropriate polling interval for my script. Scriptr theoretically allows for it to be run once per minute, which still wouldn't be that much of a burden for the website (it's only the equivalent of somebody loading the cinema listings page once per minute) but I settled on once every 10 minutes so that I shouldn't be in danger of hitting any sort of rate-limiting on their side.
  • I also learned that Scriptr has its own persistent local storage, allowing my script to retain its own metadata across runs (e.g. what is the next date that we're looking for).
  • I wrote some simple Javascript to query the relevant endpoint, retrieve JSON, parse the films in the response, and determine whether it contained new data for next week.

Now, once a week, I get a new email in my inbox from each of my four local cinemas, showing me which films they're going to be screening. After only a few weeks, I'm certain that I've already hit ROI on the few hours that I spent preparing that script; that's my favourite thing about "Practical Automation", it's much easier to see measurable benefits in a short space of time.

Please feel free to take my source code, explore with it, and maybe see whether other cinema chains have their own endpoints for which you could adapt this script!

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus