diff options
-rw-r--r-- | feedgetter.py | 4 | ||||
-rw-r--r-- | pyAggr3g470r.py | 37 |
2 files changed, 25 insertions, 16 deletions
diff --git a/feedgetter.py b/feedgetter.py index a51515fe..8c2d6e4c 100644 --- a/feedgetter.py +++ b/feedgetter.py @@ -12,6 +12,8 @@ import sqlite3 import threading import feedparser +from datetime import datetime + url_finders = [ \ re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\),\\\"]"), \ re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?"), \ @@ -84,7 +86,7 @@ class FeedGetter(object): for article in a_feed['entries']: try: self.c.execute('insert into rss_feed values (?,?,?,?,?)', (\ - "-".join([str(i) for i in list(article.updated_parsed)]), \ + datetime(*article.updated_parsed[:6]), \ a_feed.feed.title.encode('utf-8'), \ a_feed.feed.link.encode('utf-8'), \ article.title.encode('utf-8'), \ diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 839bdc90..bc6f6340 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -54,8 +54,9 @@ class Root: '">' + dic[rss_feed][0][1].encode('utf-8') + "</a></h2>" for article in dic[rss_feed]: - html += '<a href="' + article[3].encode('utf-8') + \ - '">' + article[2].encode('utf-8') + "</a><br />" + html += article[0].encode('utf-8') + " - " + \ + '<a href="' + article[3].encode('utf-8') + \ + '">' + article[2].encode('utf-8') + "</a><br />" html += htmlfooter return html @@ -67,19 +68,25 @@ class Root: def retrieve_feed(self): - conn = sqlite3.connect("./var/feed.db", isolation_level = None) - c = conn.cursor() - list_of_articles = c.execute("SELECT * FROM rss_feed").fetchall() - c.close() - - 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])) - - return dic + list_of_articles = None + try: + conn = sqlite3.connect("./var/feed.db", isolation_level = None) + c = conn.cursor() + list_of_articles = c.execute("SELECT * FROM rss_feed").fetchall() + c.close() + except: + pass + + if list_of_articles is not None: + 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])) + + return dic + return {} index.exposed = True f.exposed = True |