From: Radek Czajka Date: Fri, 15 Jul 2022 09:17:32 +0000 (+0200) Subject: Fix for Legimi. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/467b414abdf8b789bef9a71a69a497c64ec19b3f?ds=inline Fix for Legimi. --- diff --git a/requirements/requirements.txt b/requirements/requirements.txt index d95985b9..cf952650 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -10,7 +10,7 @@ python-slugify python-docx==0.8.10 Wikidata==0.6.1 -librarian==2.4.5 +librarian==2.4.6 ## Django Django==3.2.14 diff --git a/src/depot/legimi.py b/src/depot/legimi.py index 1810ec57..86ad6e52 100644 --- a/src/depot/legimi.py +++ b/src/depot/legimi.py @@ -168,20 +168,21 @@ class Legimi: "url": model['Url'], } -# name=files[] -# filename -# content-type -# response: json -# success: true -# model.Url - def send_book(self, book, changes=None): wlbook = book.wldocument(librarian2=True, changes=changes) meta = wlbook.meta cover = LabelMarquiseCover(meta, width=1200).output_file() - epub_file = EpubBuilder(cover=MarquiseCover, fundraising=fundraising).build(wlbook).get_file() - mobi_file = MobiBuilder(cover=MarquiseCover, fundraising=fundraising).build(wlbook).get_file() + epub_file = EpubBuilder( + cover=MarquiseCover, + fundraising=fundraising, + base_url='file://' + book.gallery_path() + '/' + ).build(wlbook).get_file() + mobi_file = MobiBuilder( + cover=MarquiseCover, + fundraising=fundraising, + base_url='file://' + book.gallery_path() + '/' + ).build(wlbook).get_file() book_data = { "Title": meta.title, @@ -196,7 +197,7 @@ class Legimi: } if meta.isbn_html: isbn = meta.isbn_html - if isbn.upper().startswith('ISBN '): + if isbn.upper().startswith(('ISBN ', 'ISBN-')): isbn = isbn[5:] isbn = isbn.strip() book_data['Isbn'] = isbn diff --git a/src/depot/models.py b/src/depot/models.py index b68b5365..23b6d9f3 100644 --- a/src/depot/models.py +++ b/src/depot/models.py @@ -154,6 +154,7 @@ class LegimiBookPublish(models.Model): self.legimichunkpublish_set.order_by('change__chunk__number') ] legimi.send_book(self.book, changes=changes) + legimi.edit_sale(self.book) except Exception: self.status = 110 self.error = traceback.format_exc()