Skip to content
Snippets Groups Projects
Commit 7f2d5345 authored by ale's avatar ale
Browse files

Allow passing a key to the Google Books API

parent 4601272a
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import (
"crypto/md5"
"encoding/xml"
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
......@@ -14,6 +15,8 @@ import (
"time"
)
var googleAPIKey = flag.String("google-api-key", "", "Google API key")
type googleBooksRefiner struct{}
func (r *googleBooksRefiner) Name() string {
......@@ -155,6 +158,9 @@ func (r *googleBooksRefiner) Lookup(m *Metadata) ([]*Metadata, error) {
}
values := make(url.Values)
values.Set("q", qstr)
if *googleAPIKey != "" {
values.Set("key", *googleAPIKey)
}
uri := "http://books.google.com/books/feeds/volumes?" + values.Encode()
resp, err := googleBooksGet(uri)
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment