def RecvXmlToObject(data): xml = ET.fromstring(data) root = xml.getchildren() playerNum = xml.find('playerNum') pNum = playerNum.text event = xml.find('event') evento = event.text position = xml.find('position') pos = position.text return info_receive.InfoReceive(pNum,evento,pos)
def __init__(self,wp='wp.xml',testing=False,do_images=True): self.wp = wp self.testing = testing self.do_images = do_images self.xml = None self.pivot_items_xml = '' self.images = [] self.dzc_output = 'dzc_output' self.blurb_max_len = 500 if self.testing: doc = minidom.parseString(testentry) else: f = codecs.open(self.wp, 'r', 'utf-8') xml = f.read() f.close() if xml.find('xmlns:atom="http://www.w3.org/2005/Atom"') == -1: xml = xml.replace('xmlns:wp="http://wordpress.org/export/1.0/"', 'xmlns:wp="http://wordpress.org/export/1.0/" xmlns:atom="http://www.w3.org/2005/Atom"') f = codecs.open(self.wp, 'w', 'utf-8') f.write(xml) f.close() doc = minidom.parse(self.wp) self.items = doc.getElementsByTagName('item')
def process(self, pyfile): xml = xml.etree.ElementTree.fromstring(self.load(self.XML_API % self.get_id(pyfile.url))) status = xml.findtext("./status/statuscode") if status != "ok": self.fail(_("Error retrieving manifest")) video = xml.find("video") title = video.findtext("information/title") pyfile.name = title target_url = sorted((v for v in video.iter("formitaet") if self.video_valid(v)), key=self.video_key)[-1].findtext("url") self.download(target_url)
def process(self, pyfile): xml = xml.etree.ElementTree.fromstring( self.load(self.XML_API % self.get_id(pyfile.url))) status = xml.findtext("./status/statuscode") if status != "ok": self.fail(_("Error retrieving manifest")) video = xml.find("video") title = video.findtext("information/title") pyfile.name = title target_url = sorted( (v for v in video.iter("formitaet") if self.video_valid(v)), key=self.video_key)[-1].findtext("url") self.download(target_url)