goodreadsh icon indicating copy to clipboard operation
goodreadsh copied to clipboard

Searches can find an incorrect book

Open WaterSibilantFalling opened this issue 6 years ago • 3 comments

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

WaterSibilantFalling avatar Aug 13 '19 22:08 WaterSibilantFalling

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.

WaterSibilantFalling avatar Aug 13 '19 23:08 WaterSibilantFalling

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.

danishprakash avatar Sep 08 '19 17:09 danishprakash

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

WaterSibilantFalling avatar Sep 09 '19 09:09 WaterSibilantFalling