Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searches can find an incorrect book #5

Open
WaterSibilantFalling opened this issue Aug 13, 2019 · 3 comments
Open

Searches can find an incorrect book #5

WaterSibilantFalling opened this issue Aug 13, 2019 · 3 comments

Comments

@WaterSibilantFalling
Copy link

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
Copy link
Author

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.

@danishprakash
Copy link
Owner

danishprakash commented Sep 8, 2019

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.

@WaterSibilantFalling
Copy link
Author

WaterSibilantFalling commented Sep 9, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants