1
0
Fork 0

Load author data with fedireads connector

This commit is contained in:
Mouse Reeve 2020-05-09 12:09:40 -07:00
parent bb01834a31
commit 093945e7fb
9 changed files with 73 additions and 25 deletions

View file

@ -79,9 +79,30 @@ class AbstractConnector(ABC):
''' simple function to save data to a book '''
update_from_mappings(book, data, self.book_mappings)
book.save()
authors = self.get_authors_from_data(data)
for author in authors:
book.authors.add(author)
if authors:
book.author_text = ', '.join(a.name for a in authors)
book.save()
cover = self.get_cover_from_data(data)
if cover:
book.cover.save(*cover, save=True)
return book
@abstractmethod
def get_authors_from_data(self, data):
''' load author data '''
@abstractmethod
def get_cover_from_data(self, data):
''' load cover '''
@abstractmethod
def parse_search_data(self, data):
''' turn the result json from a search into a list '''