Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
0x43
eBookHub-backend
Commits
1153a5c1
Commit
1153a5c1
authored
Mar 19, 2019
by
Patrick van der Leer
Browse files
crap for tomorrow, stupid api quota/limit
parent
94a182a8
Pipeline
#318
failed with stage
in 2 minutes and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
eBookHub/source/google.py
View file @
1153a5c1
from
collections
import
OrderedDict
import
json
from
googleapiclient.discovery
import
build
,
Resource
from
googleapiclient.http
import
HttpMockSequence
from
eBookHub
import
cache
from
eBookHub.parser.exceptions
import
NoResultsException
...
...
@@ -14,7 +15,27 @@ class GoogleBooksClient(SourceAbstract):
def
init_app
(
self
,
app
=
None
):
super
().
init_app
(
app
)
self
.
client
=
build
(
'books'
,
'v1'
,
developerKey
=
app
.
config
.
get
(
"GOOGLE_BOOKS_DEV_KEY"
))
if
app
.
testing
:
resp_raw
=
json
.
dumps
({
"kind"
:
"books#volumes"
,
"totalItems"
:
0
,
})
http
=
HttpMockSequence
([({
'status'
:
'200'
},
resp_raw
)
for
_
in
range
(
10
)])
self
.
client
=
build
(
'books'
,
'v1'
,
http
=
http
,
developerKey
=
app
.
config
.
get
(
"GOOGLE_BOOKS_DEV_KEY"
)
)
else
:
import
httplib2
httplib2
.
Http
(
cache
=
".cache"
)
self
.
client
=
build
(
'books'
,
'v1'
,
http
=
httplib2
.
Http
(
cache
=
".cache"
),
developerKey
=
app
.
config
.
get
(
"GOOGLE_BOOKS_DEV_KEY"
)
)
assert
isinstance
(
self
.
client
,
Resource
)
@
cache
.
memoize
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment