Allow wl disconnect.
[redakcja.git] / src / depot / legimi.py
index 1810ec5..f61bbfd 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,
@@ -189,6 +190,8 @@ class Legimi:
             "Year": str(date.today().year),
 
             'GenreId': str(self.get_genre(wlbook)),
             "Year": str(date.today().year),
 
             'GenreId': str(self.get_genre(wlbook)),
+            'themaCategories': ';'.join(meta.thema),
+            'thema-search': '',
             'Isbn': '',
             'LanguageLocale': lang_code_3to2(meta.language),
 
             'Isbn': '',
             'LanguageLocale': lang_code_3to2(meta.language),
 
@@ -196,7 +199,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
@@ -350,7 +353,7 @@ class Legimi:
     def edit(self, legimi_id, data):
         current = {
             'ValidationTrue': 'true',
     def edit(self, legimi_id, data):
         current = {
             'ValidationTrue': 'true',
-            'Is': legimi_id
+            'Id': legimi_id
         }
 
         current.update(data)
         }
 
         current.update(data)