#Configure these variables before using! AuthorName = "FirstName LastName" AuthorEmail = "test@example.com" """ ChangeLog --------------- v0.2.1 * Fixed url-encoding bug v0.2 * Initial --------------- New versions may periodically show up at: http://thefire.us/code/pypodgen/ Copyright (c) 2008 Paul McMillan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ #This script should work in Python Version 2.6 and 3.0 from urllib import quote import os print "PyPodGen v0.2.1. Send bugs to Paul@TheFire.us.\n" f = open(raw_input("Output filename: "), 'w') out = """ %s %s %s Copyright (c) %s PyPodGen v0.2.1 en-us no """ % (AuthorName, AuthorName, AuthorEmail, AuthorName) def nt(prompt, *elementnames): out = "" input = raw_input(prompt + ": ") for e in elementnames: out += "<%s>%s\n" % (e, input, e) return out out += nt("Podcast Title", "title", "itunes:subtitle") out += nt("Podcast Description", "itunes:summary", "description") pubdate = nt("Publication Date", "pubDate") out += pubdate out += nt("Podcast Link", "link") baseurl = raw_input("URL of the directory which contains files (including /):\n") baseurl = quote(baseurl, ":/") #don't quote the : in http://... filedir = raw_input("local path to the files:\n") for curfile in os.listdir(filedir): itemlink = baseurl + quote(curfile) out += """ %s %s %s %s no """ % (curfile, curfile, itemlink, itemlink, pubdate) out += "\n\n" f.write(out) print "Wrote podcast to %s" % f.name f.close()