The TVDB Google App Script
Let's learn something new!
My girlfriend Becky and I enjoy watching TV shows together. So much so, in fact, that we've started putting together a spreadsheet of the shows the need to binge watch together. So just for the hell of it, I threw together a rather basic (and messy) Google App Script that lives in the spreadsheet, which pulls information from The TVDB regarding how many episodes there are and how long it would take to binge watch all the shows (roughly).
So let's talk about the actual script. You can find the whole thing in the Gist below, a slightly tidied up and revised version. You'll need an API key from The TVDB, and I highly recommend you check out their API docs so you know exactly what sort of info and routes we're using.
Essentially, what happens in this. First, we search (using
searchTvdb(show, network)) for the specific show, using the network to
filter out results in case there are multiple shows with the same name.
Next, we take the showId it returns and query TVDB for the info
corresponding to the show -- we're most interested in the average
runtime from this query. We also ask TVDB for the summary of the
episodes, which returns the number of seasons, episodes aired, and so
on. We aggregate all this data into one clump of data and then throw it
into the spreadsheet.
It's very inefficient, I realize that. There are plenty of things I could probably improve performance wise, however it works fine. I expect the more shows in the spreadsheet the longer it will take (about 12 seconds with a 14 item list), but I'll refine a bit in the future.
"If everyone demanded peace instead of another television set, then there'd be peace." -- John Lennon (Probably)