optionally send api key

This commit is contained in:
j 2016-01-25 16:38:57 +05:30
parent c03f72b47c
commit b5be527aca
1 changed files with 4 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import ox.web.google
import stdnum.isbn
from .utils import find_isbns, get_language, decode_html_data, to_isbn13
import settings
import logging
logger = logging.getLogger(__name__)
@ -40,6 +41,9 @@ def info(key, value):
if key not in ('isbn', 'lccn', 'oclc'):
raise IOError('unknwon key %s' % key)
url = 'https://www.googleapis.com/books/v1/volumes?q=%s:%s' % (key, value)
api_key = settings.server.get('google_api_key')
if api_key:
url += '&key=' + api_key
if api_limit.error:
raise IOError(url)
while not api_limit.consume(1):