Skip to content

Instantly share code, notes, and snippets.

@shabegom
Created November 14, 2021 23:11
Show Gist options
  • Save shabegom/934d168802249a27873a69b124d185d6 to your computer and use it in GitHub Desktop.
Save shabegom/934d168802249a27873a69b124d185d6 to your computer and use it in GitHub Desktop.
update movie
<%*
const files = app.vault.getFiles()
.filter(file => file.path.includes("Movies"))
.filter(file => {
const frontmatter = app.metadataCache.getFileCache(file).frontmatter
if (frontmatter && frontmatter.watched && frontmatter.watched === "N") {
return true
} else {
return false
}
})
const movieToUpdate = await tp.system.suggester(item => item.basename, files, false, "Which Movie to Update?")
if (movieToUpdate) {
const rating = `**Rating**:: ${await tp.system.suggester(["⭐️","⭐️⭐️","⭐️⭐️⭐️","⭐️⭐️⭐️⭐️","⭐️⭐️⭐️⭐️⭐️"],["⭐️","⭐️⭐️","⭐️⭐️⭐️","⭐️⭐️⭐️⭐️","⭐️⭐️⭐️⭐️⭐️"])}`
const review = `**Review**:: ${await tp.system.prompt("Review")}`
const content = await app.vault.read(movieToUpdate)
const newContent = content.concat("\n"+rating+"\n"+review).replace("watched: N", "watched: Y")
await app.vault.modify(movieToUpdate, newContent)
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment