diff --git a/README.md b/README.md index aa95ea3..54a77ff 100644 --- a/README.md +++ b/README.md @@ -116,11 +116,16 @@ 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}} ``` @@ -136,6 +141,11 @@ 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, @@ -172,6 +182,16 @@ Please find here a definition of the possible variables to be used in your templ `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. diff --git a/script_googleBooks_quickAdd.js b/script_googleBooks_quickAdd.js index acd9fd6..eef425e 100644 --- a/script_googleBooks_quickAdd.js +++ b/script_googleBooks_quickAdd.js @@ -9,18 +9,18 @@ const API_KEY = "Google Books API Key" const GOODREADS_URL = "https://www.goodreads.com/search?qid=&q=" module.exports = { - entry: start, - settings: { - name: "Books script", - author: "Elaws", - options: { - [API_KEY]: { - type: "text", - defaultValue: "", - placeholder: "Google Books API Key", - } - }, - }, + entry: start, + settings: { + name: "Books script", + author: "Elaws", + options: { + [API_KEY]: { + type: "text", + defaultValue: "", + placeholder: "Google Books API Key", + } + }, + }, }; let QuickAdd; @@ -94,6 +94,7 @@ async function start(params, settings) { authors: formatList(selectedBook.authors), isbn10: `${ISBN.ISBN10 ? ISBN.ISBN10 : " "}`, isbn13: `${ISBN.ISBN13 ? ISBN.ISBN13 : " "}`, + // An URL to the GoodReads page of the book using its ISBN. // May fail if ISBN returned by Google Books is not in Goodreads database. goodreadsURL: `${ISBN.ISBN13 ? GOODREADS_URL + ISBN.ISBN13 : (ISBN.ISBN10 ? GOODREADS_URL + ISBN.ISBN10 : " ")}`, @@ -102,8 +103,18 @@ async function start(params, settings) { release: `${selectedBook.publishedDate ? (new Date((selectedBook.publishedDate))).getFullYear() : " "}`, // Squares of different color to tag Obsidian's note, depending if book has already been read or not. tag: `${isRead ? "\u{0001F7E7}" : "\u{0001F7E5}"}`, + // Main Category reported for the book + genre: `${selectedBook.categories ? selectedBook.categories : "N/A"}`, // A rating for the read book, /10. rating: myRating, + // The global average review * 2 to get /10 + avRating: `${selectedBook.averageRating ? selectedBook.averageRating * 2 : 0 }`, + // For mature audiences or not? + mature: `${selectedBook.maturityRating ? selectedBook.maturityRating : "NA" }`, + // Pages reported in book + pageCount: `${selectedBook.pageCount ? selectedBook.pageCount : 0 }`, + // blurb + bookDesc: `${selectedBook.description ? selectedBook.description : "No Description Reported" }`, // Is the book already read ? 1 if yes, 0 otherwise. read: `${isRead ? "1" : "0"}`, // Who recommended the book to me? @@ -157,13 +168,13 @@ async function getByQuery(query) { if(searchResults.error) { - notice("Request failed"); - throw new Error("Request failed"); + notice("Request failed"); + throw new Error("Request failed"); } if (searchResults.totalItems == 0) { - notice("No results found."); - throw new Error("No results found."); + notice("No results found."); + throw new Error("No results found."); } return searchResults.items; @@ -185,7 +196,7 @@ async function apiGet(query) { let finalURL = new URL(API_URL); finalURL.searchParams.append("q", query); - finalURL.searchParams.append("key", Settings[API_KEY]); + finalURL.searchParams.append("key", Settings[API_KEY]); log(finalURL.href);