aboutsummaryrefslogtreecommitdiff
path: root/export.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2011-10-25 00:05:21 +0200
committercedricbonhomme <devnull@localhost>2011-10-25 00:05:21 +0200
commit4a6706c867582b44f0fa8f6a8ea0223bf9376342 (patch)
treebb4a016a11d59b8fed2dc9fa23703900907b847d /export.py
parentRefactored export functions properly. The appropriate export function of the ... (diff)
downloadnewspipe-4a6706c867582b44f0fa8f6a8ea0223bf9376342.tar.gz
newspipe-4a6706c867582b44f0fa8f6a8ea0223bf9376342.tar.bz2
newspipe-4a6706c867582b44f0fa8f6a8ea0223bf9376342.zip
It is now possible to export all the database in the ePub format.
Diffstat (limited to 'export.py')
-rw-r--r--export.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/export.py b/export.py
index 9883eb65..cfe26e0d 100644
--- a/export.py
+++ b/export.py
@@ -157,4 +157,29 @@ def export_html(feeds):
content += htmlfooter
with open(name, "w") as f:
- f.write(content) \ No newline at end of file
+ f.write(content)
+
+def export_epub(feeds):
+ """
+ Export the articles given in parameter in ePub files.
+ """
+ from epub import ez_epub
+ for feed in feeds.values():
+ # creates folder for each stream
+ folder = utils.path + "/var/export/epub/" + \
+ utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower())
+ try:
+ os.makedirs(folder)
+ except OSError:
+ # directories already exists (not a problem)
+ pass
+
+ for article in feed.articles.values():
+ name = article.article_date.strip().replace(' ', '_')
+ name = os.path.normpath(folder + "/" + name + ".epub")
+
+ section = ez_epub.Section()
+ section.title = article.article_title.decode('utf-8')
+ section.paragraphs = [utils.clear_string(article.article_description).decode('utf-8')]
+ ez_epub.makeBook(article.article_title.decode('utf-8'), [feed.feed_title.decode('utf-8')], [section], \
+ name, lang='en-US', cover=None) \ No newline at end of file
bgstack15