Skip to content

Instantly share code, notes, and snippets.

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

Embed
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.