Skip to content

Searches can find an incorrect book #5

@WaterSibilantFalling

Description

@WaterSibilantFalling

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions