From 467b414abdf8b789bef9a71a69a497c64ec19b3f Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 15 Jul 2022 11:17:32 +0200 Subject: [PATCH 1/1] Fix for Legimi. --- requirements/requirements.txt | 2 +- src/depot/legimi.py | 21 +++++++++++---------- src/depot/models.py | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) 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() -- 2.20.1