New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix case-sensitive OPML feed parser #46
Conversation
The OPML spec seems to be ambiguous on the subject of case-sensitivity. As a result, OPML feeds that are exported from podcatchers may have uppercase attributes (i.e., `URL` vs `url`). This patch will find attributes of `xml.etree.ElementTree.Element` objects in a case-insensitive way which side-steps the problem.
Nice catch, and special thanks for adding a unit test ;-) |
Sure, here's my OPML as exported from the podcast app on mysqueezebox.com <?xml version="1.0" encoding="utf-8" ?>
<opml version="1.1">
<head title="Podcasts">
<expansionState></expansionState>
</head>
<body>
<outline URL="http://feeds.99percentinvisible.org/99percentinvisible" text="99% Invisible" type="link" />
<outline URL="http://www.npr.org/rss/podcast.php?id=381444908" text="Fresh Air" type="link" />
<outline URL="http://radioproject.libsyn.com/rss" text="Making Contact" type="link" />
<outline URL="http://feeds.wnyc.org/radiolab" text="Radiolab" type="link" />
<outline URL="http://feeds.stownpodcast.org/stownpodcast" text="S-Town" type="link" />
<outline URL="http://feeds.serialpodcast.org/serialpodcast" text="Serial" type="link" />
<outline URL="http://feeds.hearstartup.com/hearstartup" text="StartUp Podcast" type="link" />
<outline URL="http://www.npr.org/rss/rss.php?id=37" text="All Songs Considered" type="link" />
<outline URL="http://www.econlib.org/library/EconTalk.xml" text="EconTalk" type="link" />
<outline URL="http://feeds.thisamericanlife.org/talpodcast" text="This American Life" type="link" />
<outline URL="http://www.thebrewingnetwork.com/feed/cybi/" text="Can You Brew It" type="link" />
<outline URL="http://www.thebrewingnetwork.com/feed/bws/" text="Brewing With Style" type="link" />
<outline URL="http://feeds.wnyc.org/tnypoliticalscene" text="The New Yorker: Politics and More" type="link" />
<outline URL="http://www.npr.org/rss/podcast.php?id=510289" text="Planet Money" type="link" />
<outline URL="http://www.bbc.co.uk/programmes/b006qykl/episodes/downloads.rss" text="In Our Time" type="link" />
<outline URL="http://www.bbc.co.uk/programmes/b00nrtd2/episodes/downloads.rss" text="A History of the World in 100 Objects" type="link" />
<outline URL="http://feeds.propublica.org/propublica/podcast" text="ProPublica Podcast" type="link" />
<outline URL="http://feeds.soundcloud.com/users/soundcloud:users:70607212/sounds.rss" text="This is Hell!" type="link" />
<outline URL="http://feeds.trumpconlaw.com/TrumpConLaw" text="What Trump Can Teach Us About Con Law" type="link" />
<outline URL="http://feeds.gimletmedia.com/mysteryshow" text="Mystery Show" type="link" />
<outline URL="http://feeds.earhustlesq.com/earhustlesq" text="Ear Hustle" type="link" />
<outline URL="https://feeds.feedburner.com/RevisionistHistory" text="Revisionist History" type="link" />
<outline URL="http://rss.art19.com/levar-burton-reads" text="LeVar Burton Reads" type="link" />
<outline URL="http://thrillingadventurehour.libsyn.com/rss" text="Thrilling Adventure Hour" type="link" />
<outline URL="https://feeds.podtrac.com/zKq6WZZLTlbM" text="The Daily" type="link" />
<outline URL="http://adventurezone.libsyn.com/rss" text="The Adventure Zone" type="link" />
<outline URL="http://feeds.megaphone.fm/watergate" text="Slow Burn: A Podcast About Watergate" type="link" />
<outline URL="http://feeds.wnyc.org/moreperfect?format=xml" text="Radiolab Presents: More Perfect" type="link" />
</body>
</opml> |
Thanks! I'm wondering if it wouldn't be preferable to limit the case-insensitive handling to url/URL only. |
Suggestion works for me. I'll close this one in favor or #47 rather than add another commit here. |
The OPML spec seems to be ambiguous on the subject of case-sensitivity.
As a result, OPML feeds that are exported from podcatchers may have
uppercase attributes (i.e.,
URL
vsurl
). This patch will findattributes of
xml.etree.ElementTree.Element
objects in acase-insensitive way which side-steps the problem.
I ran into this importing my podcast opml from mysqueezebox.com. Adding this OPML as the
browse_root
caused a stack-trace in my mopidy log:The reason, of course, is that the
url
attribute in my OPML feed is actually theURL
attribute.