Load covers in fedireads connector
This commit is contained in:
@ -94,6 +94,27 @@ class AbstractConnector(ABC):
|
||||
return book
|
||||
|
||||
|
||||
def update_book(self, book, data=None):
|
||||
''' load new data '''
|
||||
if not book.sync and not book.sync_cover:
|
||||
return
|
||||
|
||||
if not data:
|
||||
key = getattr(book, self.key_name)
|
||||
data = self.load_book_data(key)
|
||||
|
||||
if book.sync_cover:
|
||||
book.cover.save(*self.get_cover_from_data(data), save=True)
|
||||
if book.sync:
|
||||
book = self.update_book_from_data(book, data)
|
||||
return book
|
||||
|
||||
|
||||
def load_book_data(self, remote_id):
|
||||
''' default method for loading book data '''
|
||||
return get_data(remote_id)
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def get_authors_from_data(self, data):
|
||||
''' load author data '''
|
||||
@ -131,12 +152,6 @@ class AbstractConnector(ABC):
|
||||
# return book model obj
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def update_book(self, book_obj, data=None):
|
||||
''' sync a book with the canonical remote copy '''
|
||||
# return book model obj
|
||||
|
||||
|
||||
def update_from_mappings(obj, data, mappings):
|
||||
''' assign data to model with mappings '''
|
||||
noop = lambda x: x
|
||||
|
Reference in New Issue
Block a user