mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 00:26:33 +00:00
Save source_url in connectors
This commit is contained in:
parent
54b5f0097b
commit
16fec1b6d5
3 changed files with 6 additions and 11 deletions
|
@ -20,8 +20,6 @@ def get_book(book):
|
|||
'misc_identifiers',
|
||||
|
||||
'source_url',
|
||||
'sync',
|
||||
'last_sync_date',
|
||||
|
||||
'description',
|
||||
'language',
|
||||
|
|
|
@ -54,21 +54,17 @@ class Connector(AbstractConnector):
|
|||
data = response.json()
|
||||
|
||||
# great, we can update our book.
|
||||
noop = lambda x: x
|
||||
formatters = {
|
||||
'published_date': get_date,
|
||||
'first_published_date': get_date,
|
||||
mappings = {
|
||||
'published_date': ('published_date', get_date),
|
||||
'first_published_date': ('first_published_date', get_date),
|
||||
}
|
||||
for (key, value) in data.items():
|
||||
formatter = formatters[key] if key in formatters else noop
|
||||
book = update_from_mappings(book, data, mappings)
|
||||
|
||||
if self.has_attr(book, key):
|
||||
book.__setattr__(key, formatter(value))
|
||||
book.source_url = response.url
|
||||
book.save()
|
||||
|
||||
if data.get('parent_work'):
|
||||
work = self.get_or_create_book(data.get('parent_work'))
|
||||
|
||||
book.parent_work = work
|
||||
|
||||
for author_blob in data.get('authors', []):
|
||||
|
|
|
@ -81,6 +81,7 @@ class Connector(AbstractConnector):
|
|||
if 'goodreads' in data['identifiers']:
|
||||
book.goodreads_key = data['identifiers']['goodreads']
|
||||
|
||||
book.source_url = response.url
|
||||
book.save()
|
||||
|
||||
# this book sure as heck better be an edition
|
||||
|
|
Loading…
Reference in a new issue