January 16, 2023

Goodreads to Notion

This post is a WIP/ WOL. Please comment if you are interested for me to share quickly a final solution/ want to motivate me getting this done.

I have the idea to use Notion for tracking my reading and especially take reading notes.
I use mainly Goodreads to manage the books I have or plan to read/buy and also its community feature to share with other reading friends.
Now I would like a seamless handling between both tools i.e. avoid manually entering of books in Notion and automatic synchronization from Goodreads to Notion.
Moreover, I would like also to track my expenses related to books.

Benchmarking

There is one notion template (https://www.notionreads.com) but not free that allows to add books to Notion easily.
There is no real sync tool between Goodreads and Notion.

There is a tool to import CSV to notion with a Sync feature: https://github.com/vzhd1701/csv2notion (Python based, compiled exe)

Alternative solutions

I have thought about using something else than Goodreads. 
StoryGraph export does not provide an easy book Id and therefore no easy way to get for example the book cover automatically. 

Challenges

Goodreads export does not contain Date read started. 

Raw concept

Track Amazon purchases in Google Sheets
Export Goodreads to CSV (manually, no API)
Expand Cover url (Google Script)
Expand Date Start reading (HttpGet)
Merge Price / Purchase Info (second Table, JOIN)
Owned from 'wishlist' tag
One-click sync to Notion (Google Sheets-> csv2notion) or alternative: https://hightouch.com/integrations/google-sheets-source-to-notion
alternative Zapier https://zapier.com/sign-up?template=597590&next=%2Fwebintent%2Fcreate-zap%3Ftemplate%3D597590%26attempt_id%3Df91006ca-9025-45d0-a974-8a8584787985

Usage

Export Goodreads to CSV

You can export your Goodreads library to a CSV file by going to https://www.goodreads.com/review/import
Click on the button Export Library (1)
Once the export is finished you can download the CSV file by clicking on "Your export from $date" (2)



Import Goodreads to Google Sheets

In Google Sheets go to File -> Import
Upload the CSV file downloaded in previous step
Update previous sheet if already existing by selecting Import location=Replace current sheet

Implementation

Google Sheets Script to get Goodreads Id from Amazon ASIN

function amazon2GR(ASIN) {
// returns GoodReads Id from Amazon ASIN
 //var ASIN ="B08H177WQP"
  if (ASIN =="") {
    return ;
  }
  var url = "https://www.goodreads.com/search?q=" + ASIN;
  var responseText = UrlFetchApp.fetch(url).getContentText();
  // <a class="bookTitle" itemprop="url" href="/book/show/27863178-on-love?from_search=true&amp;from_srp=true&amp;qid=H4bSF8oHE3&amp;rank=1">
  var rx = /<a class="bookTitle" .*href="\/book\/show\/(.*?)\-/
var match = responseText.match(rx);
return match[1];
}

Google Sheets script to get the book cover URL from Goodread Book Id

The Script looks like this:

function getBookCover(GRId) {
  //var GRId ="157066095"
  var url = "https://www.goodreads.com/book/show/" + GRId
  var responseText = UrlFetchApp.fetch(url).getContentText();
  var rx = /<div class="BookCover__image">(.|\n)*?src="(.*?)"/
var match = responseText.match(rx)
return match[2]
}

No comments:

Post a Comment