Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
liber
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
liber
Commits
3b4b6075
Commit
3b4b6075
authored
7 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Use a phrase query for the title on google books
Should help improve the quality of matches.
parent
c9254c36
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
googlebooks.go
+4
-3
4 additions, 3 deletions
googlebooks.go
with
4 additions
and
3 deletions
googlebooks.go
+
4
−
3
View file @
3b4b6075
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"fmt"
"fmt"
"io"
"io"
"io/ioutil"
"io/ioutil"
"log"
"net/http"
"net/http"
"net/url"
"net/url"
"path/filepath"
"path/filepath"
...
@@ -79,9 +80,7 @@ func googleBooksQuery(m *Metadata) string {
...
@@ -79,9 +80,7 @@ func googleBooksQuery(m *Metadata) string {
// If we have explicitly tagged metadata, use it.
// If we have explicitly tagged metadata, use it.
if
len
(
m
.
Title
)
>
0
{
if
len
(
m
.
Title
)
>
0
{
for
_
,
s
:=
range
strings
.
Fields
(
m
.
Title
)
{
query
=
append
(
query
,
fmt
.
Sprintf
(
"intitle:
\"
%s
\"
"
,
m
.
Title
))
query
=
append
(
query
,
fmt
.
Sprintf
(
"intitle:%s"
,
s
))
}
}
}
if
len
(
m
.
Creator
)
>
0
{
if
len
(
m
.
Creator
)
>
0
{
for
_
,
author
:=
range
m
.
Creator
{
for
_
,
author
:=
range
m
.
Creator
{
...
@@ -161,6 +160,7 @@ func (r *googleBooksRefiner) Lookup(m *Metadata) ([]*Metadata, error) {
...
@@ -161,6 +160,7 @@ func (r *googleBooksRefiner) Lookup(m *Metadata) ([]*Metadata, error) {
if
qstr
==
""
{
if
qstr
==
""
{
return
nil
,
errors
.
New
(
"insufficient metadata for query"
)
return
nil
,
errors
.
New
(
"insufficient metadata for query"
)
}
}
log
.
Printf
(
"googlebooks query: %s"
,
qstr
)
values
:=
make
(
url
.
Values
)
values
:=
make
(
url
.
Values
)
values
.
Set
(
"q"
,
qstr
)
values
.
Set
(
"q"
,
qstr
)
if
*
googleAPIKey
!=
""
{
if
*
googleAPIKey
!=
""
{
...
@@ -169,6 +169,7 @@ func (r *googleBooksRefiner) Lookup(m *Metadata) ([]*Metadata, error) {
...
@@ -169,6 +169,7 @@ func (r *googleBooksRefiner) Lookup(m *Metadata) ([]*Metadata, error) {
uri
:=
"http://books.google.com/books/feeds/volumes?"
+
values
.
Encode
()
uri
:=
"http://books.google.com/books/feeds/volumes?"
+
values
.
Encode
()
resp
,
err
:=
googleBooksGet
(
uri
)
resp
,
err
:=
googleBooksGet
(
uri
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"googlebooks error: %v"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment