goodreadsh
goodreadsh copied to clipboard
Searches can find an incorrect book
If there is a MUCH more popular book with a vaguely similar name, the much-more-popular book will be returned instead.
Incorrect:
goodreads book -a "the Art Of Invisibility"
Scott McCloud
Correct
./goodreads book -a "the Art Of Invisibility"
Kevin D. Mitnick
The solution is to wrap the book's name in quotes in the API call:
Rather than:
--author|-a )
curl -s -X "GET" --data "key=$DEVELOPER_KEY" --data "q=$3" "https://www.goodreads.com/search.xml" \
| grep "<name>.*" \
| sed "s/^[ \t]*//g" \
| sed "s/<[^>]*>//g" \
| awk 'NR==1 {print $0}'
use:
--author|-a )
curl -s -X "GET" --data "key=$DEVELOPER_KEY" --data "q=\"$3\"" "https://www.goodreads.com/search.xml" \
| grep "<name>.*" \
| sed "s/^[ \t]*//g" \
| sed "s/<[^>]*>//g" \
| awk 'NR==1 {print $0}'
where $3, the book's name string, is wrapped in \" quotes
As I have pushed this to my fork, this change will be added to my previous pull requests. AFAIK, there's nothing one can do about this (all unaccepted commits being bundled into the one PR) without branching.
Thanks for raising this issue @AbsurdMagpieScrutinies
The solution is to wrap the book's name in quotes in the API call:
Is this documented somewhere? I might have missed it somehow. Would love to read more on this before merging this.
By including \" around the text, " is passed inte the search string.
Rather than
Some Book Name
which could be ' Book Name the Some'
the exact string
"Some Book Name"
with quotes is seen by goodreads/ so it matches correctly