aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--feedgetter.py20
-rw-r--r--var/feed.lst2
2 files changed, 14 insertions, 8 deletions
diff --git a/feedgetter.py b/feedgetter.py
index 0884f7e1..5a560763 100644
--- a/feedgetter.py
+++ b/feedgetter.py
@@ -38,8 +38,9 @@ def retrieve_feed():
"""
conn = sqlite3.connect("./var/feed.db", isolation_level = None)
c = conn.cursor()
- c.execute('''create table rss_feed
- (date text, feed_title text, feed_site_link text, article_title text , article_link text)''')
+ c.execute('''create table if not exists rss_feed
+ (date text, feed_title text, feed_site_link text, \
+ article_title text, article_link text PRIMARY KEY)''')
for a_feed in feeds_file.readlines():
# test if the URL is well formed
@@ -63,12 +64,15 @@ def retrieve_feed():
# when all jobs are done, insert articles in the base
for a_feed in feeds_list:
for article in a_feed['entries']:
- c.execute('insert into rss_feed values (?,?,?,?,?)', (\
- "-".join([str(i) for i in list(article.updated_parsed)]), \
- a_feed.feed.title.encode('utf-8'), \
- a_feed.feed.link.encode('utf-8'), \
- article.title.encode('utf-8'), \
- article.link.encode('utf-8')))
+ try:
+ c.execute('insert into rss_feed values (?,?,?,?,?)', (\
+ "-".join([str(i) for i in list(article.updated_parsed)]), \
+ a_feed.feed.title.encode('utf-8'), \
+ a_feed.feed.link.encode('utf-8'), \
+ article.title.encode('utf-8'), \
+ article.link.encode('utf-8')))
+ except sqlite3.IntegrityError:
+ pass
conn.commit()
c.close()
diff --git a/var/feed.lst b/var/feed.lst
index b967eadc..e525e3d6 100644
--- a/var/feed.lst
+++ b/var/feed.lst
@@ -8,3 +8,5 @@ http://linuxfr.org/backend/news-homepage/rss20.rss
http://rss.slashdot.org/Slashdot/slashdot
http://theinvisiblethings.blogspot.com/feeds/posts/default
http://torvalds-family.blogspot.com/feeds/posts/default
+http://www.python.org/channews.rdf
+http://www.kde.org/dotkdeorg.rdf
bgstack15