X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/db255ed9d242c56b010061fbdef8de9b696869d4..634abe44a671e272552f0016155211ae91be09de:/src/depot/legimi.py diff --git a/src/depot/legimi.py b/src/depot/legimi.py index 1810ec57..464eecad 100644 --- a/src/depot/legimi.py +++ b/src/depot/legimi.py @@ -168,27 +168,35 @@ 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() + + thema = [] + if meta.thema_main: + thema.append(meta.thema_main) + thema.extend(meta.thema) + book_data = { "Title": meta.title, "Author": ", ".join(p.readable() for p in meta.authors), "Year": str(date.today().year), 'GenreId': str(self.get_genre(wlbook)), + 'themaCategories': ';'.join(thema), + 'thema-search': '', 'Isbn': '', 'LanguageLocale': lang_code_3to2(meta.language), @@ -196,7 +204,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 @@ -286,12 +294,13 @@ class Legimi: for p in wlbook.meta.genres ) + '

' - if wlbook.meta.audience: + # TODO: Move away from using audiences for this. + if wlbook.meta.audience in ('L', 'SP1', 'SP2', 'SP3', 'SP4'): description += '

{} to lektura szkolna.'.format(wlbook.meta.title) if wlbook.tree.find('//pe') is not None: description += '
Ebook {title} zawiera przypisy opracowane specjalnie dla uczennic i uczniów {school}.'.format( title=wlbook.meta.title, - school='szkoły podstawowej' if wlbook.meta.audience == 'SP' else 'liceum i technikum' + school='szkoły podstawowej' if wlbook.meta.audience.startswith('SP') else 'liceum i technikum' ) description += '

' return description @@ -350,7 +359,7 @@ class Legimi: def edit(self, legimi_id, data): current = { 'ValidationTrue': 'true', - 'Is': legimi_id + 'Id': legimi_id } current.update(data)