"Author": ", ".join(p.readable() for p in meta.authors),
"Year": meta.created_at[:4],
- 'GenreId': '11', # TODO
+ 'GenreId': str(self.get_genre(wlbook)),
'Isbn': '',
'LanguageLocale': lang_code_3to2(meta.language),
- 'Description': description_add,
+ 'Description': self.get_description(wlbook),
}
if meta.isbn_html:
isbn = meta.isbn_html
files_data = {}
- abstract = wlbook.tree.find('.//abstrakt')
- if abstract is not None:
- book_data['Description'] = transform_abstrakt(abstract)
-
-
cover_data = self.upload(
(meta.url.slug + '.jpg', cover.get_file(), 'image/jpeg')
)
if wlbook.meta.audience:
description += '<p><em>{}</em> to lektura szkolna.'.format(wlbook.meta.title)
- if wlbook.tree.find('//pe'):
+ if wlbook.tree.find('//pe') is not None:
description += '<br>Ebook <em>{title}</em> 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'
description += '</p>'
return description
+ def get_genre(self, wlbook):
+ epoch_map = {
+ 'Starożytność': 80,
+ 'Średniowiecze': 81,
+ 'Renesans': 82,
+ 'Barok': 83,
+ 'Oświecenie': 84,
+ 'Romantyzm': 85,
+ 'Pozytywizm': 86,
+ 'Modernizm': 87,
+ 'Dwudziestolecie międzywojenne': 88,
+ 'Współczesność': 90,
+ }
+
+ for epoch in wlbook.meta.epochs:
+ if epoch in epoch_map:
+ return epoch_map[epoch]
+ return 11
+
def create_book(self, book_data, files_data):
data = {
'createValidationTrue': 'true',