If this script helped you and you wish to contribute :)
This script allows you to easily insert a book note into your Obsidian vault using Quickadd plugin by @chhoumann. Now also works on Mobile (make sure you use latest QuickAdd) ! Possible to query book using :
- a book title or ISBN (10 or 13).
- (optional) author name
It's also possible to query book using author name only (just skip book title prompt).
The (i)
prefix in search suggestions indicates that an image is available for this book.
We use Google Books API to get the book information.
An API KEY for Google Books is needed to use this script : it can be obtained here. Steps to obtain this key are detailed below (see How to obtain Google Book's API key).
The script and this tutorial are based on Macro_MovieAndSeriesScript.md by @chhoumann.
Please never run a script that you don't understand. I cannot and will not be liable for any damage caused by the use of this script. Regularly make a backup of your Obsidian's vault !
- Visit this website.
- Login using your Google account.
- When prompted, accept the terms of use :
- Click on "Create a project" :
- Enter a project name :
- Back on the credentials page, click on "Create credentials" :
- In the menu that appeared, select "API Key" :
- You should see your API key. Close the window :
- Here is your API key :
- We must now enable Google Books API for this key. Back on the credentials page, click on "APIs and services" :
- Click on "Enable APIs and services" :
- Enter "Google books" in the search bar that appeared :
- Select "Books API" :
- Enable Google Books API by clicking on "Enable" :
- Make sure you use latest Quickadd version (at least 0.5.1) !
- Save the script to your vault somewhere. Make sure it is saved as a JavaScript file, meaning that it has the
.js
at the end. - Create a new template in your designated templates folder. Example template is provided below.
- Open the Macro Manager by opening the QuickAdd plugin settings and clicking
Manage Macros
. - Create a new Macro - you decide what to name it.
- Add the user script to the command list.
- Add a new Template step to the macro. This will be what creates the note in your vault. Settings are as follows:
- Set the template path to the template you created.
- Enable File Name Format and use
{{VALUE:fileName}}
as the file name format. You can specify this however you like. ThefileName
value is the name of book without illegal file name characters. - The remaining settings are for you to specify depending on your needs.
- Click on the cog icon to the right of the script step to configure the script settings. This should allow you to enter the API key you got from Google Books API. Make sure no spaces are inserted before or after the key !
- Go back out to your QuickAdd main menu and add a new Macro choice. Again, you decide the name. This is what activates the macro.
- Attach the Macro to the Macro Choice you just created. Do so by clicking the cog ⚙ icon and selecting it.
You can now use the macro to create notes with book information in your vault !
Please also find a definition of the variables used in this template below (see : Template variable definitions).
# {{VALUE:title}}
Title:: {{VALUE:title}}
linking:: [[% Novels]]
Tags:: #📥/📚/{{VALUE:tag}}
Author:: {{VALUE:authors}}
Publish date:: {{VALUE:release}}
Cover:: {{VALUE:thumbnail}}
ISBN10:: {{VALUE:isbn10}}
ISBN13:: {{VALUE:isbn13}}
URL:: [Goodreads]({{VALUE:goodreadsURL}})
Genre:: {{VALUE:genre}}
PageCount:: {{VALUE:pageCount}}
AverageRating:: {{VALUE:avRating}}
Rating:: {{VALUE:rating}}
Maturity:: {{VALUE:mature}}
Read:: {{VALUE:read}}
Recommender:: {{VALUE:recommender}}
Date:: {{DATE}}
Comment:: {{VALUE:comment}}
BookDescription:: {{VALUE: bookDesc}}
Here is the dataview query used in the demo (replace PATH
by your videogames notes path) :
TABLE WITHOUT ID
("[[" + file.name + "|" + Title + "]]") AS Title,
Author,
publish-date AS "Publish date",
("![coverImg|100](" + Cover + ")") as Cover,
rating AS "Rating",
AverageRating AS "Average Rating",
Maturity AS "Maturity Rating",
PageCount AS "Page Count",
BookDescription AS "Book Description",
Genre,
Recommender,
Comment,
Date,
URL
FROM "PATH"
SORT Title
The banner at the top of the document is rendered using Obsidian-banners plugin.
Please find here a definition of the possible variables to be used in your template. Simply write {{VALUE:name}}
in your template, and replace name
by the desired book data, including :
fileName
: Title of the book without illegal characters. Possibly used in template configuration to name your file.
title
: The title of the book.
tag
: A colored square that is red if unread, orange if read.
authors
: Book's author.
release
: The year this edition of the book was published.
thumbnail
: A book cover, whenever possible.
isbn10
: The ISBN 10 of the book.
isbn13
: The ISBN 13 of the book.
goodreadsURL
: An URL that uses the ISBN to request Goodreads book page. This may fail if ISBN returned by Google is not in the database of Goodreads.
rating
: Your book rating, /10.
avRating
: Average rating from all ratings in API.
genre
: The reported genre of the book.
pageCount
: Total number of pages in this book.
mature
: Is this book rated mature or not?
bookDesc
: What is the blurb of the book?
read
: If you read the book, this equals 1, otherwise 0 (this helps to filter dataview query).
recommender
: The person (or organization, etc...) that recommended the book to you.
comment
: A short personal comment on the book.