Matt’s
Comments
(group member since May 02, 2018)
Matt’s
comments
from the Goodreads Developers group.
Showing 1-6 of 6

Jul 03, 2020 06:26AM

#!/usr/bin/python3
import re
from xml.etree import ElementTree
import requests
USER_ID = 10_052_745
API_KEY = "[% REDACTED %]"
r = requests.get(f"https://www.goodreads.com/review/list...", params={
"key": API_KEY,
"v": 2,
"per_page": 10,
"page": 1
})
x = ElementTree.fromstring(r.content)
for r in x.findall("reviews/"):
print("title:", r.find("book/title_without_series").text)
print("exclusive shelf:", r.find("shelves/shelf[@exclusive='true']").get("name"))
print("all shelves:")
for shelf in r.findall("shelves/"):
shelf_name = shelf.get("name")
shelf_id = shelf.get("id")
print(f"* {shelf_name} ({shelf_id})")
print()
# vim: ts=4 : sw=4 : et
that'll produce something like this:
title: Nightblind
exclusive shelf: library
all shelves:
* library (264428736)
* borrowed (219480356)
title: Island
exclusive shelf: to-read
all shelves:
* to-read (33356208)

for my own use i've been manually copying/pasting the dates out of the web interface, though obviously that's not particularly scalable.

is this a book you added straight to your Read shelf?
_
¹ there doesn't appear to be any way of getting the latter through the API.

An example: https://www.goodreads.com/book/show/5... shows an Edition Language of English. However,
"""
gr_key=[% key %]
get_gr_book() {
book_id=$1
gr_xml=$(curl -s https://www.goodreads.com/book/show/$...)
echo -n 'Author: '; echo "$gr_xml" | xml_grep --text_only //GoodreadsResponse/book/authors/author[0]/name
echo -n 'Title: '; echo "$gr_xml" | xml_grep --text_only //GoodreadsResponse/book/title
echo -n 'Language: '; echo "$gr_xml" | xml_grep --text_only //GoodreadsResponse/book/language_code
echo
}
$ get_gr_book 5968469
Author: Agnes Owens
Title: The Complete Short Stories
Language:
$
"""
This does, however, work with other books:
"""
$ get_gr_book 366649
Author: Émile Zola
Title: Le Ventre de Paris (Les Rougon-Macquart, #3)
Language: fre
$
"""