def generate_xml(): tree = ET.parse(Settings.local_base_xml_filename()) root = tree.getroot() channel = root.find('channel') # Alter the title of this podcast to append ' (Cached)' title = channel.find('title') title.text += ' (Cached)' # Remove any existing items from the channel tag in the base XML file items = channel.findall("item") for item in items: channel.remove(item) # Now... add every episode we've got for number in range(1, Settings.get_highest_episode()+1): print "Processing " + str(number) try: channel.append(process_episode(number)) except Exception as e: print "Something bad happened while processing episode " + str(number) print "{0}".format(e) print "{0}".format(sys.exc_info()[0]) print "{0}".format(sys.exc_info()[1]) traceback.print_tb(sys.exc_info()[2]) #output = prettify(root).encode('utf-8') #output = prettify(channel).encode('utf-8') #with open(LOCAL_RSS_FILE, "w") as f: # f.write(output) tree.write(Settings.local_xml_filename()) print "You can download the mirrored podcast from:" print " " + Settings.local_xml_url()