Last active
April 27, 2016 03:54
-
-
Save bcantoni/051af96c4a5f69f0a314 to your computer and use it in GitHub Desktop.
Simple conversion from podcast subscription OPML file into Markdown text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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