X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/7f302cfc1fac98e08e65061111fd1395bb399209..07e5d48b0655d447b2dec96ad6e5e81e72ec4837:/apps/catalogue/models.py?ds=sidebyside diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 8c83faa53..4ef0a14e6 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -17,7 +17,7 @@ from newtagging.models import TagBase, tags_updated from newtagging import managers from catalogue.fields import JSONField -from librarian import dcparser, html, epub +from librarian import dcparser, html, epub, NoDublinCore from mutagen import id3 @@ -207,7 +207,7 @@ class Book(models.Model): def __unicode__(self): return self.title - def save(self, force_insert=False, force_update=False, reset_short_html=True, refresh_mp3=True): + def save(self, force_insert=False, force_update=False, reset_short_html=True, refresh_mp3=True, **kwargs): if reset_short_html: # Reset _short_html during save update = {} @@ -406,9 +406,12 @@ class Book(models.Model): # Create EPUB epub_file = StringIO() - epub.transform(book.xml_file, epub_file) - book.epub_file.save('%s.epub' % book.slug, ContentFile(epub_file.getvalue()), save=False) - FileRecord(slug=book.slug, type='epub', sha1=sha1(epub_file.getvalue()).hexdigest()).save() + try: + epub.transform(book.xml_file, epub_file) + book.epub_file.save('%s.epub' % book.slug, ContentFile(epub_file.getvalue()), save=False) + FileRecord(slug=book.slug, type='epub', sha1=sha1(epub_file.getvalue()).hexdigest()).save() + except NoDublinCore: + pass # Extract fragments closed_fragments, open_fragments = html.extract_fragments(book.html_file.path)