IMDB Templater Example

<%*
async function imdbSearch() {
const apiKey = "GET AN API TOKEN FROM https://omdbapi.com AND PUT IT HERE";
const searchPrompt = await tp.system.prompt("What movie?")
    const response = await fetch(
      `https://omdbapi.com/?apikey=${apiKey}&s=${searchPrompt}`
    ).then(res => res.json())
    if (response.Search[0]) {
       const choice = await tp.system.suggester(choice => `${choice.Title} ${choice.Year}`, response.Search, false, "Choose which Movie")
       if (choice) {
           let movie = await fetch(
             `https://omdbapi.com/?apikey=${apiKey}&i=${choice.imdbID}`
           ).then(res => res.json())
           if (movie) {
	        const item = []
			const title = `# ${movie.Title}`
			const poster = `<img src=${movie.Poster} width="300px" />`
			const director = `**Director**:: ${movie.Director.split(",").map(director => `[[${director.trim()}]]`).join(", ")}`
            const writer = `**Writer**:: ${movie.Writer.split(",").map(writer => `[[${writer.trim()}]]`).join(", ")}`
			const cast = `**Starring**:: ${movie.Actors.split(",").map(star => `[[${star.trim()}]]`).join(", ")}`
			const year = `**Year**:: [[${movie.Year}]]`
			const runtime = `**Runtime**:: ${movie.Runtime}`
			const genre = `**Genre**:: ${movie.Genre.split(", ").map(genre => "#" + genre).join(", ")}`
			const plot = `**Plot**:: ${movie.Plot}`
			const link = `**IMDB**:: [Link](https://www.imdb.com/title/${choice.imdbID}/)`
			const watched = await tp.system.suggester(["Yes","No"],[true,false],false,"Watched Yet?")
			const rating = watched ? `**Rating**:: ${await tp.system.suggester(["⭐️","⭐️⭐️","⭐️⭐️⭐️","⭐️⭐️⭐️⭐️","⭐️⭐️⭐️⭐️⭐️"],["⭐️","⭐️⭐️","⭐️⭐️⭐️","⭐️⭐️⭐️⭐️","⭐️⭐️⭐️⭐️⭐️"])}` : undefined
			const isWatched = watched ? 'watched: Y' : 'watched: N'
			const frontmatter = ['---',"tags: movie",isWatched,"---"].join("\n")
			item.push(frontmatter,title,poster,"","### Metadata",director,writer,cast,year,runtime,genre,link,plot)
			if (rating) {
				item.push(rating)
			}
			const review = watched ? `**Review**:: ${await tp.system.prompt("Review")}` : undefined
			if (review) {
				item.push(review)
			}
			await tp.file.move("Movies/"+movie.Title.replace(/[:/]/, " -"))
           return item.join("\n")
           }
       }
    }
}
tR += await imdbSearch()
%>
IMDB Templater Example
Interactive graph