Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%*
- async function imdbSearch() {
- const apiKey = YOU_omdb_TOKEN;
- 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 = ``
- const director = `director: ${movie.Director.split(",").map(director => `\n - "[[${director.trim()}]]"`).join("")}`
- const writer = `writer: ${movie.Writer.split(",").map(writer => `\n - "[[${writer.trim()}]]"`).join("")}`
- const cast = `starring: ${movie.Actors.split(",").map(star => `\n - "[[${star.trim()}]]"`).join("")}`
- const year = `year: ${movie.Year}`
- const runtime = `runtime: ${movie.Runtime}`
- const genre = `tags: ${movie.Genre.split(", ").map(genre => "\n - " + genre).join("")}`
- const plot = `plot: ${movie.Plot.replace(/[:/]/, ",")}`
- const link = `IMDB: 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.prompt("Rathing", "10", true)}` : "rating: "
- const isWatched = watched ? 'watched: true' : 'watched: false'
- const frontmatter = ['---',"topic: Movie",isWatched,director,writer,cast,year,runtime,genre,link,plot,rating,"---"].join("\n")
- item.push(frontmatter,title,'\n\n',poster,'\n')
- const review = watched ? `Review:: ${await tp.system.prompt("Review")}` : "Review:: "
- if (review) {
- item.push(review)
- }
- await tp.file.move("Movies/"+movie.Title.replace(/[:/]/, " -"))
- return item.join("\n")
- }
- }
- }
- }
- tR += await imdbSearch()
- %>
Advertisement
Add Comment
Please, Sign In to add comment