Created
April 8, 2022 12:32
-
-
Save basilioss/62adab009eeff3b9e043d88ccb74ef82 to your computer and use it in GitHub Desktop.
This is an Obsidian Templater script that generates frontmatter for literature notes from Goodreads link
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
---<%* | |
let url = await tp.system.clipboard() | |
let page = await tp.obsidian.request({url}) | |
let p = new DOMParser() | |
let doc = p.parseFromString(page, "text/html") | |
let $ = s => doc.querySelector(s) | |
let $A = s => doc.querySelectorAll(s) | |
%> | |
title: "<% $("h1[id='bookTitle']").innerHTML.trim() %>" | |
authors: [<%* let authors = $A("span[itemprop=name]") | |
var keys = Array.from(authors, authors => authors.textContent) | |
tR += keys.join(', ') %>] | |
isbn: <% $("meta[property='books:isbn']").content %> | |
genres: [<%* let genres = $A("a[class='actionLinkLite bookPageGenreLink']") | |
var keys = Array.from(genres, genres => genres.textContent.toLowerCase()) | |
tR += keys.join(', ') %>] | |
cover: "<% $("img[id='coverImage']").src %>" | |
--- |
Thanks for this! 👏 I expanded my version to also get the publication date.
@AdamBuchweitz Thanks for sharing!
Happy to! I just updated mine again to rename the file to the titled of the book, shortened to avoid non-word characters like colons.
Further development will be continued here: https://github.com/basilioss/obsidian-scrapers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
QUICK DEMO: https://user-images.githubusercontent.com/71596800/178814251-1da1a660-7779-4645-8db3-d456f7fe66c8.mp4