Set connectors on books

This commit is contained in:
Mouse Reeve 2020-03-28 16:01:02 -07:00
parent 1a33290267
commit 0c9aad730d
4 changed files with 6 additions and 4 deletions

View file

@ -19,7 +19,7 @@ def get_or_create_book(key):
def search(query):
''' ya '''
''' try an external datasource for books '''
connector = get_connector()
return connector.search(query)

View file

@ -10,7 +10,7 @@ class AbstractConnector(ABC):
def __init__(self, identifier):
# load connector settings
info = models.Connector.objects.get(identifier=identifier)
self.model = info
self.connector = info
self.url = info.base_url
self.covers_url = info.covers_url
@ -21,8 +21,8 @@ class AbstractConnector(ABC):
def is_available(self):
''' check if you're allowed to use this connector '''
if self.model.max_query_count is not None:
if self.model.query_count >= self.model.max_query_count:
if self.connector.max_query_count is not None:
if self.connector.query_count >= self.connector.max_query_count:
return False
return True

View file

@ -61,6 +61,7 @@ class Connector(AbstractConnector):
book = update_from_mappings(book, data, mappings)
book.source_url = response.url
book.connector = self.connector
book.save()
if data.get('parent_work'):

View file

@ -82,6 +82,7 @@ class Connector(AbstractConnector):
book.goodreads_key = data['identifiers']['goodreads']
book.source_url = response.url
book.connector = self.connector
book.save()
# this book sure as heck better be an edition