| 70 | | channel = root.find('.//channel') |
| 71 | | if channel: |
| 72 | | title = channel.find('title') |
| 73 | | self.title = ET.iselement(title) and title.text or 'None' |
| 74 | | description = channel.find('description') |
| 75 | | self.description = ET.iselement(description) and description.text or 'None' |
| 76 | | pubDate = channel.find('pubDate') |
| 77 | | self.pubDate = ET.iselement(pubDate) and pubDate.text or 'None' |
| 78 | | items = channel.findall('item') |
| 79 | | for item in items: |
| 80 | | newItem = self.Item() |
| 81 | | element = item.find('title') |
| 82 | | newItem.title = element.text or 'None' |
| 83 | | element = item.find('description') |
| 84 | | newItem.description = element.text or 'None' |
| 85 | | element = item.find('pubDate') |
| 86 | | if element is not None: |
| 87 | | newItem.date = element.text or 'None' |
| 88 | | enclosure = item.find('enclosure') |
| 89 | | if enclosure is not None: |
| 90 | | newItem.url = 'url' in enclosure.attrib and enclosure.attrib['url'] or 'None' |
| 91 | | newItem.type = 'type' in enclosure.attrib and enclosure.attrib['type'] or 'None' |
| 92 | | newItem.length = 'length' in enclosure.attrib and enclosure.attrib['length'] or 'None' |
| 93 | | self.items.append(newItem) |
| | 70 | try: |
| | 71 | channel = root.find('.//channel') |
| | 72 | if channel: |
| | 73 | title = channel.find('title') |
| | 74 | self.title = ET.iselement(title) and title.text or 'None' |
| | 75 | description = channel.find('description') |
| | 76 | self.description = ET.iselement(description) and description.text or 'None' |
| | 77 | pubDate = channel.find('pubDate') |
| | 78 | self.pubDate = ET.iselement(pubDate) and pubDate.text or 'None' |
| | 79 | items = channel.findall('item') |
| | 80 | for item in items: |
| | 81 | newItem = self.Item() |
| | 82 | element = item.find('title') |
| | 83 | newItem.title = element.text or 'None' |
| | 84 | element = item.find('description') |
| | 85 | newItem.description = element.text or 'None' |
| | 86 | element = item.find('pubDate') |
| | 87 | if element is not None: |
| | 88 | newItem.date = element.text or 'None' |
| | 89 | enclosure = item.find('enclosure') |
| | 90 | if enclosure is not None: |
| | 91 | newItem.url = 'url' in enclosure.attrib and enclosure.attrib['url'] or 'None' |
| | 92 | newItem.type = 'type' in enclosure.attrib and enclosure.attrib['type'] or 'None' |
| | 93 | newItem.length = 'length' in enclosure.attrib and enclosure.attrib['length'] or 'None' |
| | 94 | self.items.append(newItem) |
| | 95 | except AttributeError: |
| | 96 | pass |