aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2012-05-01 14:34:04 +0200
committercedricbonhomme <devnull@localhost>2012-05-01 14:34:04 +0200
commit8b02c05b2e7e4d419aca7323d81afbf99eddb8bc (patch)
tree7c8326c885977c94139ab94cea257598bd3cecd4
parenturlsafe_b64encode is replaced by SHA1 for id of articles. (diff)
downloadnewspipe-8b02c05b2e7e4d419aca7323d81afbf99eddb8bc.tar.gz
newspipe-8b02c05b2e7e4d419aca7323d81afbf99eddb8bc.tar.bz2
newspipe-8b02c05b2e7e4d419aca7323d81afbf99eddb8bc.zip
Export to text files OK.
-rw-r--r--source/export.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/source/export.py b/source/export.py
index 97b185a4..bd98cc79 100644
--- a/source/export.py
+++ b/source/export.py
@@ -103,29 +103,30 @@ def export_html(mongo_db):
with open(conf.path + "/var/export/webzine/" + "index.html", "w") as f:
f.write(index.encode('utf-8'))
-def export_txt(feeds):
+def export_txt(mongo_db):
"""
Export the articles given in parameter in text files.
"""
- for feed in feeds.values():
+ feeds = mongo_db.get_all_feeds()
+ for feed in feeds:
# creates folder for each stream
- folder = utils.path + "/var/export/txt/" + \
- utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower())
+ folder = conf.path + "/var/export/txt/" + \
+ utils.normalize_filename(feed["feed_title"].strip().replace(':', '').lower().encode('utf-8'))
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(' ', '_')
+ for article in mongo_db.get_articles_from_collection(feed["feed_id"]):
+ name = article["article_date"].ctime().strip().replace(' ', '_')
name = os.path.normpath(folder + "/" + name + ".txt")
- content = "Title: " + article.article_title + "\n\n\n"
- content += utils.clear_string(article.article_description)
+ content = "Title: " + article["article_title"] + "\n\n\n"
+ content += utils.clear_string(article["article_content"])
with open(name, "w") as f:
- f.write(content)
+ f.write(content.encode('utf-8'))
def export_epub(feeds):
"""
bgstack15