Skip to content

Instantly share code, notes, and snippets.

@mojowen
Last active March 18, 2021 18:37
Show Gist options
  • Save mojowen/989a3dd5ce7d123916c8e36b1b024200 to your computer and use it in GitHub Desktop.
Save mojowen/989a3dd5ce7d123916c8e36b1b024200 to your computer and use it in GitHub Desktop.
Make a list of actors from a given list of moves in themoviedb.org
// HOW TO USE
// 1. Visit https://api.themoviedb.org/what in your browser
// 2. Open your javascript console
// 3. Update the two constants below
// 4. Paste into the console
const API_KEY = "ADD-YOUR-API-KEY"
const LIST_ID = "ADD-LIST-ID"
const { items } = await (await fetch(`https://api.themoviedb.org/3/list/${LIST_ID}?api_key=${API_KEY}`)).json()
const actors = (await Promise.all(items.map(async ({ title, id }) => {
const { cast } = (await (await fetch(`https://api.themoviedb.org/3/movie/${id}/credits?api_key=${API_KEY}`)).json())
return cast.map(({ name }) => `"${name}","${title}"`)
}))
const listed = actors.reduce((tot, next) => tot.concat(next), [])).join("\n")
console.log(listed)
copy(listed) // Will save in your clipboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment