Created
November 14, 2021 23:11
-
-
Save shabegom/934d168802249a27873a69b124d185d6 to your computer and use it in GitHub Desktop.
update movie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
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