Commit 7f2d5345 authored by ale's avatar ale

Allow passing a key to the Google Books API

parent 4601272a
Pipeline #453 passed with stages
in 1 minute and 28 seconds
......@@ -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 {
......
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