Greetings!
Has been yet another long period since my last post, but hopefully the type of content makes up for it. Today I'm writing about a need that I had to document my entire movie collection in Google Sheets, because some that were on my local network, some on DVD, some on my Playstation Video account and as well as my small collection in Google TV. All in all there is currently over 500 movies, and growing.
So the spreadsheet is fine on its own, but something nice and "pretty" was needed to list, search and filter by the movie's attributes. I first got an API key to be used with OMDB API. This allows me to get a JSON of the movie's IMDB attributes with a search from the title. I then added two functions in the "Apps Script" component of the sheet:
From here, I could call the function to search (from a cell) with:
=API(CONCAT("http://www.omdbapi.com/?apikey=*******&t=",ENCODEURL(A1)))
That would return the JSON (assuming A1 is the cell where the title of the movie is), and then I can use something like:
=JSONKey(K1,"Year")
To return the Year the movie was produced (assuming K1 is the cell where the JSON is). If you want to sort/filter this sheet, it is best to copy/paste the values from the returned data of these functions, to both reduce the number of calls you make to the API, and I find it works better for Google Sheets as well.
From here, go to https://script.google.com and create a new project. Within the "Code.gs" window, use the following code:
This assumes the following:
- Column K has your full JSON data
- Column I has the location of where the movie is in your library (DVD, Google, etc.), and
- Column L has any external path that you may want to use in order to play the movie from the new application
Comments
Post a Comment