diff options
author | cedricbonhomme <devnull@localhost> | 2010-01-31 12:45:38 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2010-01-31 12:45:38 +0100 |
commit | 7eaee7d8c2f06a8ed15c326e31f9724ee75e8040 (patch) | |
tree | a7388e4d773984a8989b7fc87e3e2ed1e30275b0 | |
parent | All date are parsed into the standard Python datetime format. (diff) | |
download | newspipe-7eaee7d8c2f06a8ed15c326e31f9724ee75e8040.tar.gz newspipe-7eaee7d8c2f06a8ed15c326e31f9724ee75e8040.tar.bz2 newspipe-7eaee7d8c2f06a8ed15c326e31f9724ee75e8040.zip |
Sort articles by date for each feeds.
-rw-r--r-- | feedgetter.py | 12 | ||||
-rw-r--r-- | pyAggr3g470r.py | 5 |
2 files changed, 14 insertions, 3 deletions
diff --git a/feedgetter.py b/feedgetter.py index 8c2d6e4c..a99d8a29 100644 --- a/feedgetter.py +++ b/feedgetter.py @@ -69,7 +69,8 @@ class FeedGetter(object): self.c = self.conn.cursor() self.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)''') + article_title text, article_link text PRIMARY KEY, \ + article_content text)''') # add the articles in the base self.add_into_sqlite(feedparser.parse(the_good_url)) @@ -85,12 +86,17 @@ class FeedGetter(object): """ for article in a_feed['entries']: try: - self.c.execute('insert into rss_feed values (?,?,?,?,?)', (\ + content = article.description.encode('utf-8') + except Exception, e: + content = "No description" + try: + self.c.execute('insert into rss_feed values (?,?,?,?,?,?)', (\ datetime(*article.updated_parsed[:6]), \ a_feed.feed.title.encode('utf-8'), \ a_feed.feed.link.encode('utf-8'), \ article.title.encode('utf-8'), \ - article.link.encode('utf-8'))) + article.link.encode('utf-8'), \ + content)) except sqlite3.IntegrityError: pass diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index bc6f6340..34f6e226 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -81,10 +81,15 @@ class Root: dic = {} for article in list_of_articles: if article[2] not in dic: + dic[article[2]] = [(article[0], article[1], article[3], article[4])] else: dic[article[2]].append((article[0], article[1], article[3], article[4])) + # sort articles by date for each feeds + for feeds in dic.keys(): + dic[article[2]].sort(lambda x,y: cmp(y[0], x[0])) + return dic return {} |