XMLParse2: add basic support for content:encoded extension attributes
authorDavid Adam (zanchey) <[email protected]>
Mon, 27 Dec 2010 16:27:12 +0000 (00:27 +0800)
committerDavid Adam (zanchey) <[email protected]>
Mon, 27 Dec 2010 16:27:12 +0000 (00:27 +0800)
XMLParse2.py

index 978b418..488a344 100644 (file)
@@ -106,7 +106,11 @@ class XMLParse:
                                except: blogItem.itemDate = 0
                        else:
                                blogItem.itemDate       = 0
                                except: blogItem.itemDate = 0
                        else:
                                blogItem.itemDate       = 0
-                       if entry.has_key('description'):
+                       if entry.has_key('content'):
+                               # get the contents of the first item with a text/html type
+                               # no feeds without a text/html type have been encountered in the wild, but who knows
+                               blogItem.contents       = [content['value'] for content in entry['content'] if content['type'] == 'text/html'][0]
+                       elif entry.has_key('description'):
                                blogItem.contents       = entry['description']
                        else:
                                blogItem.contents       = '(entry could not be retrieved)'
                                blogItem.contents       = entry['description']
                        else:
                                blogItem.contents       = '(entry could not be retrieved)'

UCC git Repository :: git.ucc.asn.au