#!/usr/bin/env python # -*- coding: UTF-8 -*- import httplib, sys, urlparse def usage(): print "Enclose 0.1 -- 30-June-2005" print print print "Usage: %s [url]" % sys.argv[0] print print "This little utility \"goes out\" and fetches the information needed" print "to add an RSS 2.0 enclosure with WordPress, in case your webserver" print "can't do it on its own." print print "Just provide an URL as an argument, and cut and paste the result into" print "the \"custom key\" section of the post page." print print "For more information, see:" print "http://www.audioactivism.org/2005/03/02/howto-podcast-with-wordpress-15/" print print "Written by Daniele Nicolucci (Jollino)." print "You can contact the author at daniele [at] nicolucci [dot] net." print print "This software is released under the Attribution-Sharealike Creative" print "Commons license, version 2.5 or later." print "For the full license, see:" print "http://creativecommons.org/licenses/by-sa/2.5/" sys.exit(1) #----------------------------------------------------------# def error(response): print "FATAL ERROR!" print "The server returned %s: %s" % (response.status, response.reason) sys.exit(2) #----------------------------------------------------------# def main(): if len(sys.argv) < 2: usage() url = sys.argv[1] if url[:7] != "http://": url = "http://"+url parts = urlparse.urlparse(url) host = parts[1] obj = parts[2] conn = httplib.HTTPConnection(host) conn.request("HEAD", obj) response = conn.getresponse() if response.status != 200: error(response) print url print response.getheader("Content-Length") print response.getheader("Content-Type") #----------------------------------------------------------# if __name__ == "__main__": main()