From c51c75b6a64ecabd6491a6dc1afd9f19d3e721c2 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 9 Feb 2025 22:39:31 -0500 Subject: [PATCH] [books] Handle authors from Google --- vrobbler/apps/books/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vrobbler/apps/books/models.py b/vrobbler/apps/books/models.py index 372841a..69db360 100644 --- a/vrobbler/apps/books/models.py +++ b/vrobbler/apps/books/models.py @@ -165,12 +165,21 @@ class Book(LongPlayScrobblableMixin): ).as_dict_with_authors_cover_and_genres() if created or overwrite: + author_list = [] + if authors: + for author_str in authors: + if author_str: + author_list.append( + Author.objects.get_or_create(name=author_str)[0] + ) + for k, v in bdict.items(): setattr(book, k, v) book.save() book.save_image_from_url(cover) book.genre.add(*genres) + book.authors.add(*author_list) return book def save_image_from_url(self, url: str, force_update: bool = False):