1 import os, xml.dom.minidom
2 from enigma import iServiceInformation
4 DUMPBIN = "/usr/lib/enigma2/python/Plugins/Extensions/HbbTV/dumpait"
5 class eAITSectionReader:
6 def __init__(self, demux, pmtid, sid):
11 self.mCommand = "%s --demux=%s --pmtid=%x --serviceid=%x"%(DUMPBIN, demux, pmtid, sid)
13 def __text(self, nodelist):
16 if node.nodeType == node.TEXT_NODE:
20 def __item(self, application, name):
21 for item in application.getElementsByTagName(name):
22 return self.__text(item.childNodes)
25 def __application(self, application):
28 if self.mVuplusBox is not None:
29 item["name"] = str(application[1])
30 item["url"] = str(application[2])
31 item["control"] = int(application[0])
32 item["orgid"] = int(application[3])
33 item["appid"] = int(application[4])
34 item["profile"] = int(application[5])
36 item["name"] = str(self.__item(application, "name"))
37 item["url"] = str(self.__item(application, "url"))
38 item["control"] = int(self.__item(application, "control"))
39 item["orgid"] = int(self.__item(application, "orgid"))
40 item["appid"] = int(self.__item(application, "appid"))
41 item["profile"] = int(self.__item(application, "profile"))
45 def doParseApplications(self):
48 if self.mVuplusBox is not None:
49 for application in self.mInfo.getInfoObject(iServiceInformation.sHBBTVUrl):
50 item = self.__application(application)
53 for application in self.mDocument.getElementsByTagName("application"):
54 item = self.__application(application)
58 def getApplicationList(self):
61 def doOpen(self, info, is_vuplusbox):
62 if is_vuplusbox is not None:
63 self.mVuplusBox = is_vuplusbox
68 try: document = os.popen(self.mCommand).read()
69 except Exception, ErrMsg:
72 if len(document) == 0:
74 document = document.decode("cp1252").encode("utf-8")
76 self.mDocument = xml.dom.minidom.parseString(document)
80 for x in self.getApplicationList():
81 print "Name :", x["name"]
82 print "URL :", x["url"]
83 print "OrgID :", x["orgid"]
84 print "AppID :", x["appid"]
85 print "Control Code :", x["control"]
86 print "Profile Code :", x["profile"]
89 def unit_test(demux, pmtid, sid):
90 reader = eAITSectionReader(demux, pmtid, sid)
92 reader.doParseApplications()
94 else: print "no data!!"
96 #unit_test('0', 0x17d4, 0x2b66)