Fixed etag value of None if a feed did not contain updates, plus parsing for gzipped...
authorYves Marcoz <ymarcoz@stromgarde.(none)>
Mon, 14 Jun 2010 22:44:46 +0000 (15:44 -0700)
committerYves Marcoz <ymarcoz@stromgarde.(none)>
Mon, 14 Jun 2010 22:44:46 +0000 (15:44 -0700)
src/feedparser.py
src/rss.py

index 476f452..e04d253 100644 (file)
@@ -2463,8 +2463,6 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer
         result['bozo_exception'] = e
         data = ''
         f = None
-    ## Fix for media:title bug
-    data = data.replace("media:title", "mediatitle")
 
     # if feed is gzip-compressed, decompress it
     if f and data and hasattr(f, 'headers'):
@@ -2487,6 +2485,9 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer
                 result['bozo_exception'] = e
                 data = ''
 
+    ## Fix for media:title bug
+    data = data.replace("media:title", "mediatitle")
+
     # save HTTP headers
     if hasattr(f, 'info'):
         info = f.info()
index a174280..a105f3d 100644 (file)
@@ -132,17 +132,20 @@ class Feed:
             tmp=feedparser.parse(self.url, etag = self.etag, modified = self.modified)
         else:
             tmp=feedparser.parse(self.url, etag = self.etag, modified = self.modified, handlers = [proxy])
-        try:
-            self.etag = tmp["etag"]
-        except KeyError:
-            pass
-        try:
-            self.modified = tmp["modified"]
-        except KeyError:
-            pass
         expiry = float(expiryTime) * 3600.
+
         # Check if the parse was succesful (number of entries > 0, else do nothing)
         if len(tmp["entries"])>0:
+           # The etag and modified value should only be updated if the content was not null
+           try:
+               self.etag = tmp["etag"]
+           except KeyError:
+               self.etag = None
+           try:
+               self.modified = tmp["modified"]
+           except KeyError:
+               self.modified = None
+           #if len(tmp["entries"])>0:
            if not isdir(configdir+self.uniqueId+".d"):
                mkdir(configdir+self.uniqueId+".d")
            try: