Commit 3b4b6075 authored by ale's avatar ale

Use a phrase query for the title on google books

Should help improve the quality of matches.
parent c9254c36
......@@ -8,6 +8,7 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"path/filepath"
......@@ -79,9 +80,7 @@ func googleBooksQuery(m *Metadata) string {
// If we have explicitly tagged metadata, use it.
if len(m.Title) > 0 {
for _, s := range strings.Fields(m.Title) {
query = append(query, fmt.Sprintf("intitle:%s", s))
}
query = append(query, fmt.Sprintf("intitle:\"%s\"", m.Title))
}
if len(m.Creator) > 0 {
for _, author := range m.Creator {
......@@ -161,6 +160,7 @@ func (r *googleBooksRefiner) Lookup(m *Metadata) ([]*Metadata, error) {
if qstr == "" {
return nil, errors.New("insufficient metadata for query")
}
log.Printf("googlebooks query: %s", qstr)
values := make(url.Values)
values.Set("q", qstr)
if *googleAPIKey != "" {
......@@ -169,6 +169,7 @@ func (r *googleBooksRefiner) Lookup(m *Metadata) ([]*Metadata, error) {
uri := "http://books.google.com/books/feeds/volumes?" + values.Encode()
resp, err := googleBooksGet(uri)
if err != nil {
log.Printf("googlebooks error: %v", err)
return nil, err
}
defer resp.Body.Close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment