Fix for Legimi.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 15 Jul 2022 09:17:32 +0000 (11:17 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 15 Jul 2022 09:19:19 +0000 (11:19 +0200)
requirements/requirements.txt
src/depot/legimi.py
src/depot/models.py

index d95985b..cf95265 100644 (file)
@@ -10,7 +10,7 @@ python-slugify
 python-docx==0.8.10
 Wikidata==0.6.1
 
 python-docx==0.8.10
 Wikidata==0.6.1
 
-librarian==2.4.5
+librarian==2.4.6
 
 ## Django
 Django==3.2.14
 
 ## Django
 Django==3.2.14
index 1810ec5..86ad6e5 100644 (file)
@@ -168,20 +168,21 @@ class Legimi:
             "url": model['Url'],
         }
 
             "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()
     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,
 
         book_data = {
             "Title": meta.title,
@@ -196,7 +197,7 @@ class Legimi:
         }
         if meta.isbn_html:
             isbn = meta.isbn_html
         }
         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
                 isbn = isbn[5:]
             isbn = isbn.strip()
             book_data['Isbn'] = isbn
index b68b536..23b6d9f 100644 (file)
@@ -154,6 +154,7 @@ class LegimiBookPublish(models.Model):
                 self.legimichunkpublish_set.order_by('change__chunk__number')
             ]
             legimi.send_book(self.book, changes=changes)
                 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()
         except Exception:
             self.status = 110
             self.error = traceback.format_exc()