X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/842685bc24daac46f562bdde7ce527fd5e3b1474..7a959df9b6d26bfc4688a0b0096a23e019eaf9ac:/src/depot/legimi.py
diff --git a/src/depot/legimi.py b/src/depot/legimi.py
index 3a6829a8..0a09f0b4 100644
--- a/src/depot/legimi.py
+++ b/src/depot/legimi.py
@@ -6,6 +6,7 @@ from librarian.html import transform_abstrakt
from librarian.builders import EpubBuilder, MobiBuilder
from librarian.cover import LegimiCornerCover, LegimiCover
import requests
+from slugify import slugify
@@ -17,6 +18,9 @@ fundraising=[
"Przekaż 1% podatku na Wolne Lektury.
\nKRS: 0000070056
\nNazwa organizacji: Fundacja Nowoczesna Polska
\nKażda wpÅacona kwota zostanie przeznaczona na rozwój Wolnych Lektur."
]
+description_add = '
KsiÄ Å¼kÄ polecajÄ Wolne Lektury â najpopularniejsza biblioteka on-line.
' + + class Legimi: #BASE_URL = 'https://wydawca.legimi.com' BASE_URL = 'https://panel.legimi.pl' @@ -82,11 +86,11 @@ class Legimi: "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': self.get_description(wlbook), } if meta.isbn_html: isbn = meta.isbn_html @@ -97,11 +101,6 @@ class Legimi: 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') ) @@ -142,6 +141,77 @@ class Legimi: book.legimi_id = legimi_id book.save(update_fields=['legimi_id']) + def get_description(self, wlbook): + description = '' + abstract = wlbook.tree.find('.//abstrakt') + if abstract is not None: + description = transform_abstrakt(abstract) + description += description_add + description += ''
+ description += ', '.join(
+ '{}'.format(
+ slugify(p.readable()),
+ p.readable(),
+ )
+ for p in wlbook.meta.authors
+ ) + '
'
+ description += '{}
'.format(
+ wlbook.meta.url.slug,
+ wlbook.meta.title
+ )
+ if wlbook.meta.translators:
+ description += 'tÅum. ' + ', '.join(p.readable() for p in wlbook.meta.translators) + '
'
+ description += 'Epoka: ' + ', '.join(
+ '{}'.format(
+ slugify(p),
+ p,
+ )
+ for p in wlbook.meta.epochs
+ ) + ' '
+ description += 'Rodzaj: ' + ', '.join(
+ '{}'.format(
+ slugify(p),
+ p,
+ )
+ for p in wlbook.meta.kinds
+ ) + ' '
+ description += 'Gatunek: ' + ', '.join(
+ '{}'.format(
+ slugify(p),
+ p,
+ )
+ for p in wlbook.meta.genres
+ ) + '
{} 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'
+ )
+ description += '