diff options
author | cedricbonhomme <devnull@localhost> | 2011-06-10 13:57:44 +0200 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2011-06-10 13:57:44 +0200 |
commit | c3ada18a3974d21679ecef6fc6e96df35da16a1b (patch) | |
tree | 066b30e88c61ab777699fbe8d7a9eebbeb0c4e58 | |
parent | Minor bugfix: Missing feed id in the URL parameter. (diff) | |
download | newspipe-c3ada18a3974d21679ecef6fc6e96df35da16a1b.tar.gz newspipe-c3ada18a3974d21679ecef6fc6e96df35da16a1b.tar.bz2 newspipe-c3ada18a3974d21679ecef6fc6e96df35da16a1b.zip |
Minor improvement: test if the published/update date for the article is present before the data base insertion
-rwxr-xr-x | feedgetter.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/feedgetter.py b/feedgetter.py index 54183b08..d272fcb1 100755 --- a/feedgetter.py +++ b/feedgetter.py @@ -133,9 +133,14 @@ class FeedGetter(object): article_title = str(BeautifulSoup(article.title)) try: + post_date = datetime(*article.updated_parsed[:6]) + except: + post_date = datetime(*article.published_parsed[:6]) + + try: # try. Will only success if the article is not already in the data base self.c.execute('insert into articles values (?, ?, ?, ?, ?, ?, ?)', (\ - datetime(*article.updated_parsed[:6]), \ + post_date, \ article_title, \ article.link.encode('utf-8'), \ description, \ @@ -158,9 +163,9 @@ class FeedGetter(object): except sqlite3.IntegrityError: # article already in the data base pass - except: + except Exception, e: # Missing information (updated_parsed, ...) - pass + print e if __name__ == "__main__": |