+ self.build_cover()
+
+ def build_cover(self):
+ width, height = 212, 300
+ try:
+ xml = self.materialize(publishable=True).encode('utf-8')
+ info = BookInfo.from_bytes(xml)
+ kwargs = {}
+ if chunk.book.project is not None:
+ if chunk.book.project.logo_mono or chunk.book.project.logo:
+ kwargs['cover_logo'] = (chunk.book.project.logo_mono or chunk.book.project.logo).path
+ cover = make_cover(info, width=width, height=height, **kwargs)
+ out = BytesIO()
+ ext = cover.ext()
+ cover.save(out)
+ self.cover.save(f'{self.slug}.{ext}', out, save=False)
+ type(self).objects.filter(pk=self.pk).update(cover=self.cover)
+ except:
+ type(self).objects.filter(pk=self.pk).update(cover='')