Create a gist now

Instantly share code, notes, and snippets.

@bcantoni /podcast.py
Last active Apr 27, 2016

What would you like to do?
Simple conversion from podcast subscription OPML file into Markdown text
#!/usr/local/bin/python
"""
Convert podcast OPML file into Markdown format suitable for blog posting
Brian Cantoni
"""
import opml
import codecs
import locale
import sys
# Wrap sys.stdout into a StreamWriter to allow writing unicode.
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
if len(sys.argv) < 2:
sys.stderr.write("Usage: podcast.py input.opml\n")
sys.exit(1)
o = opml.parse(sys.argv[1])
print u"## %s\n" % o.title
for f in o:
print u"[** %s **](%s) [[%s](%s)] \n" % (f.text, f.htmlUrl, f.type, f.xmlUrl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment