[hbbtv] upgraded.
[vuplus_dvbapp] / lib / python / Plugins / Extensions / HbbTV / aitreader.py
old mode 100755 (executable)
new mode 100644 (file)
index 1d7a713..757b0f3
@@ -1,8 +1,13 @@
 import os, xml.dom.minidom
+from enigma import iServiceInformation
 
-DUMPBIN = "/usr/lib/enigma2/python/Plugins/Extensions/HbbTV/dumpait"
+import vbcfg
+
+DUMPBIN = vbcfg.PLUGINROOT + "/dumpait"
 class eAITSectionReader:
        def __init__(self, demux, pmtid, sid):
+               self.mVuplusBox = False
+               self.mInfo = None
                self.mAppList  = []
                self.mDocument = None
                self.mCommand  = "%s --demux=%s --pmtid=%x --serviceid=%x"%(DUMPBIN, demux, pmtid, sid)
@@ -21,36 +26,58 @@ class eAITSectionReader:
 
        def __application(self, application):
                item = {}
-               item["name"]    = str(self.__item(application, "name"))
-               item["url"]     = str(self.__item(application, "url"))
-               item["control"] = int(self.__item(application, "control"))
-               item["orgid"]   = int(self.__item(application, "orgid"))
-               item["appid"]   = int(self.__item(application, "appid"))
-               item["profile"] = int(self.__item(application, "profile"))
-               #print item
+
+               if self.mVuplusBox:
+                       item["name"]    = str(application[1])
+                       item["url"]     = str(application[2])
+                       item["control"] = int(application[0])
+                       item["orgid"]   = int(application[3])
+                       item["appid"]   = int(application[4])
+                       item["profile"] = int(application[5])
+               else:
+                       item["name"]    = str(self.__item(application, "name"))
+                       item["url"]     = str(self.__item(application, "url"))
+                       item["control"] = int(self.__item(application, "control"))
+                       item["orgid"]   = int(self.__item(application, "orgid"))
+                       item["appid"]   = int(self.__item(application, "appid"))
+                       item["profile"] = int(self.__item(application, "profile"))
                return item
 
        def doParseApplications(self):
                l = []
-               for application in self.mDocument.getElementsByTagName("application"):
-                       item = self.__application(application)
-                       l.append(item)
+
+               if self.mVuplusBox:
+                       for application in self.mInfo.getInfoObject(iServiceInformation.sHBBTVUrl):
+                               item = self.__application(application)
+                               l.append(item)
+               else:
+                       for application in self.mDocument.getElementsByTagName("application"):
+                               item = self.__application(application)
+                               l.append(item)
                self.mAppList = l
 
        def getApplicationList(self):
                return self.mAppList
 
-       def doOpen(self):
+       def doOpen(self, info, is_vuplusbox):
+               if is_vuplusbox:
+                       self.mVuplusBox = is_vuplusbox
+                       self.mInfo = info
+                       return True
+
                document = ""
                try:    document = os.popen(self.mCommand).read()
                except Exception, ErrMsg:
-                       print ErrMsg
+                       vbcfg.ERR(ErrMsg)
                        return False
                if len(document) == 0:
                        return False
                document = document.decode("cp1252").encode("utf-8")
-               #print document
-               self.mDocument = xml.dom.minidom.parseString(document)
+               try:
+                       self.mDocument = xml.dom.minidom.parseString(document)
+               except Exception, ErrMsg:
+                       vbcfg.ERR("XML parse: %s" % ErrMsg)
+                       return False
                return True
 
        def doDump(self):
@@ -68,7 +95,8 @@ def unit_test(demux, pmtid, sid):
        if reader.doOpen():
                reader.doParseApplications()
                reader.doDump()
-       else:   print "no data!!"
+       else:
+               vbcfg.ERR("no data!!")
 
 #unit_test('0', 0x17d4, 0x2b66)