Skip to content

Instantly share code, notes, and snippets.

@bcantoni
Last active April 27, 2016 03:54
Show Gist options
  • Save bcantoni/051af96c4a5f69f0a314 to your computer and use it in GitHub Desktop.
Save bcantoni/051af96c4a5f69f0a314 to your computer and use it in GitHub Desktop.
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