Skip to content

Commit

Permalink
Improve parsing support for OPML files
Browse files Browse the repository at this point in the history
Ignore the case for file types, so that OPML files
with UPPERCASE type attributes also work (this is
the way ziepod and other apps write OPML files).
  • Loading branch information
thp committed Jan 7, 2010
1 parent 1b4ae50 commit db354a8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/gpodder/opml.py
Expand Up @@ -61,7 +61,7 @@ class Importer(object):
contains workarounds to support odeo.com feeds.
"""

VALID_TYPES = ( 'rss', 'link' )
VALID_TYPES = ('rss', 'link')

def __init__( self, url):
"""
Expand All @@ -76,7 +76,12 @@ def __init__( self, url):
doc = xml.dom.minidom.parseString(util.urlopen(url).read())

for outline in doc.getElementsByTagName('outline'):
if outline.getAttribute('type') in self.VALID_TYPES and outline.getAttribute('xmlUrl') or outline.getAttribute('url'):
# Make sure we are dealing with a valid link type (ignore case)
otl_type = outline.getAttribute('type')
if otl_type is None or otl_type.lower() not in self.VALID_TYPES:
continue

if outline.getAttribute('xmlUrl') or outline.getAttribute('url'):
channel = {
'url': outline.getAttribute('xmlUrl') or outline.getAttribute('url'),
'title': outline.getAttribute('title') or outline.getAttribute('text') or outline.getAttribute('xmlUrl') or outline.getAttribute('url'),
Expand Down

0 comments on commit db354a8

Please sign in to comment.