diff options
author | cedricbonhomme <devnull@localhost> | 2010-01-30 08:51:09 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2010-01-30 08:51:09 +0100 |
commit | 6eea7fef16b5bc7120cf919eeffcfe1145b58793 (patch) | |
tree | 82a7502acf9fc1fc8f6423c035e2ca1452f69db0 | |
parent | Added : UTF-8 encoding of web pages and a link for the management of feed. (diff) | |
download | newspipe-6eea7fef16b5bc7120cf919eeffcfe1145b58793.tar.gz newspipe-6eea7fef16b5bc7120cf919eeffcfe1145b58793.tar.bz2 newspipe-6eea7fef16b5bc7120cf919eeffcfe1145b58793.zip |
Added : primary key in the SQLite base and check the existence of table.
-rw-r--r-- | feedgetter.py | 20 | ||||
-rw-r--r-- | var/feed.lst | 2 |
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 |