-
-
Save sha1sum/55b07afd6c05db5cc1ff8e11fe9f2abb to your computer and use it in GitHub Desktop.
TMDB Script w/ Google Apps Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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