talraash

Untitled

Dec 3rd, 2023
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <%*
  2. async function imdbSearch() {
  3. const apiKey = YOU_omdb_TOKEN;
  4. const searchPrompt = await tp.system.prompt("What movie?");
  5. const response = await fetch(`https://omdbapi.com/?apikey=${apiKey}&s=${searchPrompt}`).then(res => res.json())
  6. if (response.Search[0]) {
  7. const choice = await tp.system.suggester(choice => `${choice.Title} ${choice.Year}`, response.Search, false, "Choose which Movie")
  8. if (choice) {
  9. let movie = await fetch(`https://omdbapi.com/?apikey=${apiKey}&i=${choice.imdbID}`).then(res => res.json())
  10. if (movie) {
  11. const item = []
  12. const title = `# ${movie.Title}`
  13. const poster = `![|300](${movie.Poster})`
  14. const director = `director: ${movie.Director.split(",").map(director => `\n - "[[${director.trim()}]]"`).join("")}`
  15. const writer = `writer: ${movie.Writer.split(",").map(writer => `\n - "[[${writer.trim()}]]"`).join("")}`
  16. const cast = `starring: ${movie.Actors.split(",").map(star => `\n - "[[${star.trim()}]]"`).join("")}`
  17. const year = `year: ${movie.Year}`
  18. const runtime = `runtime: ${movie.Runtime}`
  19. const genre = `tags: ${movie.Genre.split(", ").map(genre => "\n - " + genre).join("")}`
  20. const plot = `plot: ${movie.Plot.replace(/[:/]/, ",")}`
  21. const link = `IMDB: https://www.imdb.com/title/${choice.imdbID}/`
  22. const watched = await tp.system.suggester(["Yes","No"],[true,false],false,"Watched Yet?")
  23. const rating = watched ? `rating: ${await tp.system.prompt("Rathing", "10", true)}` : "rating: "
  24. const isWatched = watched ? 'watched: true' : 'watched: false'
  25. const frontmatter = ['---',"topic: Movie",isWatched,director,writer,cast,year,runtime,genre,link,plot,rating,"---"].join("\n")
  26. item.push(frontmatter,title,'\n\n',poster,'\n')
  27. const review = watched ? `Review:: ${await tp.system.prompt("Review")}` : "Review:: "
  28. if (review) {
  29. item.push(review)
  30. }
  31. await tp.file.move("Movies/"+movie.Title.replace(/[:/]/, " -"))
  32. return item.join("\n")
  33. }
  34. }
  35. }
  36. }
  37. tR += await imdbSearch()
  38. %>
Advertisement
Add Comment
Please, Sign In to add comment