Skip to content

Instantly share code, notes, and snippets.

@sha1sum
Forked from hello-party/tmdb.md
Last active June 4, 2022 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sha1sum/55b07afd6c05db5cc1ff8e11fe9f2abb to your computer and use it in GitHub Desktop.
Save sha1sum/55b07afd6c05db5cc1ff8e11fe9f2abb to your computer and use it in GitHub Desktop.
TMDB Script w/ Google Apps Script
/**
* Returns omdb information
*
* @param {AL3} ids
* @param {"public"|"private"} type
* @return {array} range of information from API
* @customfunction
*/
function TMDB(ids) {
var tmdbKey = 'abcd1234';
const urls = ids.map(id => `https://api.themoviedb.org/3/find/${id}?api_key=${tmdbKey}&external_source=imdb_id`)
const requests = UrlFetchApp.fetchAll(urls)
return requests.map(request => {
try {
const data = JSON.parse(request.getContentText())
data = data['movie_results'][0];
// TODO: edit these: const { Type, imdbID, Year, Title, imdbRating, Metascore, Plot, Language, Director, Actors, Awards, Runtime, Genre, Writer, Rated } = data
// TODO: and these: return [Type, imdbID, Year, Title, imdbRating, Metascore, Plot, Language, Director, Actors, Awards, Runtime, Genre, Writer, Rated]
} catch (err) {
return [err, "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment