changeset 20:d27c3ad0f4d0

Fixing update/publish time in feeds
author Walter Cruz <walter@waltercruz.com>
date Thu, 07 Aug 2008 15:49:48 -0300
parents af61cef614f5
children 69179a909897
files feed2twitter/feed2twitter/__init__.py feed2twitter/feed2twitter/readrss.py
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/feed2twitter/feed2twitter/__init__.py	Thu Aug 07 15:36:23 2008 -0300
+++ b/feed2twitter/feed2twitter/__init__.py	Thu Aug 07 15:49:48 2008 -0300
@@ -72,7 +72,10 @@
         if not lastread:
             self.twitIt(reversed(self.rss.feed['items'][:5]))
         else:
-            lista = [item for item in self.rss.feed['items'] if item['published_parsed'] > lastread]
+            try:
+                lista = [item for item in self.rss.feed['items'] if item['published_parsed'] > lastread]
+            except:
+                lista = [item for item in self.rss.feed['items'] if item['updated_parsed'] > lastread]
             self.twitIt(reversed(lista[:5]))
 
 def update():
--- a/feed2twitter/feed2twitter/readrss.py	Thu Aug 07 15:36:23 2008 -0300
+++ b/feed2twitter/feed2twitter/readrss.py	Thu Aug 07 15:49:48 2008 -0300
@@ -35,10 +35,14 @@
         if not os.path.exists(self.directory):
             mkdir(self.directory)
         output = open(self.filename, 'wb')
+        key = 'updated_parsed'
         if not item:
-            pickle.dump(self.feed['items'][0]['published_parsed'], output)
+            if 'published_parsed' in self.feed['items'][0]:
+                key = 'published_parsed'
+            pickle.dump(self.feed['items'][0][key], output)
         else:
-            pickle.dump(item['published_parsed'], output)
+            if 'published_parsed' in item:
+                pickle.dump(item[key], output)
         output.close()
 
     def getlastRead(self):