Example #1
0
	def sortEPGList(self, epglist):
		usr_ref_list = []
		serviceHandler = eServiceCenter.getInstance()
		if not config.usage.multibouquet.value:
			service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 22) || (type == 25) || (type == 134) || (type == 195)'
			bqrootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet' % (service_types_tv)
			bouquet = eServiceReference(bqrootstr)
			servicelist = serviceHandler.list(bouquet)
			if not servicelist is None:
				while True:
					service = servicelist.getNext()
					if not service.valid():
						break
					if not (service.flags & (eServiceReference.isMarker | eServiceReference.isDirectory)):
						usr_ref_list.append(service.toString())
		else:
			bqrootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
			bouquet = eServiceReference(bqrootstr)
			bouquetlist = serviceHandler.list(bouquet)
			if not bouquetlist is None:
				while True:
					bouquet = bouquetlist.getNext()
					if not bouquet.valid():
						break
					if bouquet.flags & eServiceReference.isDirectory and not bouquet.flags & eServiceReference.isInvisible:
						servicelist = serviceHandler.list(bouquet)
						if not servicelist is None:
							while True:
								service = servicelist.getNext()
								if not service.valid():
									break
								if not (service.flags & (eServiceReference.isMarker | eServiceReference.isDirectory)):
									usr_ref_list.append(service.toString())
		result = []
		if config.plugins.epgsearch.favorit_name.value:
			for e in epglist:
				for x in usr_ref_list:
					y = ':'.join(GetWithAlternative(x).split(':')[:11])
					if y == e[0]:
						new_e = (x, e[1], e[2], e[3], e[4])
						result.append(new_e)
		else:
			for e in epglist:
				for x in usr_ref_list:
					y = ':'.join(GetWithAlternative(x).split(':')[:11])
					if y == e[0]:
						result.append(e)
		return result
Example #2
0
 def resolveAlternate(self, ref, timer_state=None):
     if ref and timer_state is not None and ref.flags & eServiceReference.isGroup:
         if timer_state == 2:
             ref = getBestPlayableServiceReference(ref, eServiceReference())
         else:
             ref = eServiceReference(GetWithAlternative(ref.toString()))
     return ref
Example #3
0
def getPiconName(serviceName):
	#remove the path and name fields, and replace ':' by '_'
	fields = GetWithAlternative(serviceName).split(':', 10)[:10]
	if not fields or len(fields) < 10:
		return ""
	pngname = findPicon('_'.join(fields))
	if not pngname and not fields[6].endswith("0000"):
		#remove "sub-network" from namespace
		fields[6] = fields[6][:-4] + "0000"
		pngname = findPicon('_'.join(fields))
	if not pngname and fields[0] != '1':
		#fallback to 1 for IPTV streams
		fields[0] = '1'
		pngname = findPicon('_'.join(fields))
	if not pngname and fields[2] != '2':
		#fallback to 1 for TV services with non-standard service types
		fields[2] = '1'
		pngname = findPicon('_'.join(fields))
	if not pngname: # picon by channel name
		name = ServiceReference(serviceName).getServiceName()
		name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
		name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
		if len(name) > 0:
			pngname = findPicon(name)
			if not pngname and len(name) > 2 and name.endswith('hd'):
				pngname = findPicon(name[:-2])
	return pngname
Example #4
0
 def getPiconName(self, serviceName):
     #remove the path and name fields, and replace ":" by "_"
     fields = GetWithAlternative(serviceName).split(":", 10)[:10]
     if not fields or len(fields) < 10:
         return ""
     pngname = self.findPicon("_".join(fields))
     if not pngname and not fields[6].endswith("0000"):
         #remove "sub-network" from namespace
         fields[6] = fields[6][:-4] + "0000"
         pngname = self.findPicon("_".join(fields))
     if not pngname and fields[0] != "1":
         #fallback to 1 for IPTV streams
         fields[0] = "1"
         pngname = self.findPicon("_".join(fields))
     if not pngname and fields[2] != "2":
         #fallback to 1 for TV services with non-standard service types
         fields[2] = "1"
         pngname = self.findPicon("_".join(fields))
     if not pngname:  # picon by channel name
         name = sanitizeFilename(
             eServiceReference(serviceName).getServiceName())
         name = re.sub(
             "[^a-z0-9]", "",
             name.replace("&",
                          "and").replace("+",
                                         "plus").replace("*",
                                                         "star").lower())
         if len(name) > 0:
             pngname = self.findPicon(name)
             if not pngname and len(name) > 2 and name.endswith("hd"):
                 pngname = self.findPicon(name[:-2])
             if not pngname and len(name) > 6:
                 series = re.sub(r"s[0-9]*e[0-9]*$", "", name)
                 pngname = self.findPicon(series)
     return pngname
Example #5
0
def getLcdPiconName(serviceName):
    #remove the path and name fields, and replace ':' by '_'
    sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
    pngname = findLcdPicon(sname)
    if not pngname:
        fields = sname.split('_', 3)
        if len(fields) > 2 and fields[
                2] != '2':  #fallback to 1 for tv services with nonstandard servicetypes
            fields[2] = '1'
        if len(fields
               ) > 0 and fields[0] == '4097':  #fallback to 1 for IPTV streams
            fields[0] = '1'
        pngname = findLcdPicon('_'.join(fields))
    if not pngname:  # picon by channel name
        name = ServiceReference(serviceName).getServiceName()
        name = unicodedata.normalize('NFKD', unicode(name, 'utf_8')).encode(
            'ASCII', 'ignore')
        name = re.sub(
            '[^a-z0-9]', '',
            name.replace('&', 'and').replace('+',
                                             'plus').replace('*',
                                                             'star').lower())
        if len(name) > 0:
            pngname = findLcdPicon(name)
    return pngname
Example #6
0
def findPicon(service):
    pngname = ''
    sname = service
    s_name = sname
    if sname.startswith('1:134'):
        sname = GetWithAlternative(service)
    for protocol in ('http', 'rtmp', 'rtsp', 'mms', 'rtp'):
        pos = sname.rfind(':' + protocol)
        if pos != -1:
            sname = sname.split(protocol)[0]
            break

    pos = sname.rfind(':')
    if pos != -1:
        sname = sname[:pos].rstrip(':').replace(':', '_')
    pngname = nameCache.get(sname, '')
    if pngname == '':
        pngname = findFile(sname)
        if pngname == '':
            serviceHandler = eServiceCenter.getInstance()
            service = eServiceReference(s_name)
            if service and service is not None:
                info = serviceHandler.info(service)
                if info and info is not None:
                    service_name = info.getName(service).replace(
                        '\xc2\x86', '').replace('\xc2\x87',
                                                '').replace('/', '_')
                    print service_name
                    pngname = findFile(service_name)
        if pngname == '' and sname.startswith('4097_'):
            pngname = findFile(sname.replace('4097_', '1_', 1))
        if pngname != '':
            nameCache[sname] = pngname
    return pngname
Example #7
0
def getPiconName(serviceName, selfPiconType):
    if DBG: j00zekDEBUG('[j00zekPicons:getPiconName] >>>')
    name = 'unknown'
    sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
    pngname = findPicon(sname, selfPiconType)
    if not pngname:
        fields = sname.split('_', 3)
        isChanged = False
        if len(fields) > 2 and fields[2] != '2' and fields[2] != '1':
            fields[2] = '1'
            isChanged = True
        if len(fields) > 0 and fields[0] == '4097':
            fields[0] = '1'
            isChanged = True
        if isChanged == True:
            pngname = findPicon('_'.join(fields), selfPiconType)
    if not pngname:
        name = ServiceReference(serviceName).getServiceName()
        name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
        name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
        if len(name) > 0:
            pngname = findPicon(name, selfPiconType)
            if not pngname and len(name) > 2 and name.endswith('hd'):
                pngname = findPicon(name[:-2], selfPiconType)
    if DBG:
        j00zekDEBUG('[j00zekPicons:getPiconName] serviceName=%s, picon=%s, %s, piconFile=%s, selfPiconType=%s' %(str(serviceName),
                                                                sname, name, str(pngname), selfPiconType) )
    return pngname
Example #8
0
 def getOrbitalPos(self, ref, state):
     refstr = ''
     alternative = ''
     if hasattr(ref, 'sref'):
         refstr = str(ref.sref)
     else:
         refstr = str(ref)
     if refstr and refstr.startswith('1:134:'):
         alternative = " (A)"
         if state in (1, 2) and not hasattr(ref, 'sref'):
             current_ref = getBestPlayableServiceReference(
                 ref.ref, eServiceReference())
             if not current_ref:
                 return _("N/A") + alternative
             else:
                 refstr = current_ref.toString()
         else:
             refstr = GetWithAlternative(refstr)
     if '%3a//' in refstr:
         return "%s" % _("Stream") + alternative
     op = int(refstr.split(':', 10)[6][:-4] or "0", 16)
     if op == 0xeeee:
         return "%s" % _("DVB-T") + alternative
     if op == 0xffff:
         return "%s" % _("DVB-C") + alternative
     direction = 'E'
     if op > 1800:
         op = 3600 - op
         direction = 'W'
     return ("%d.%d\xc2\xb0%s") % (op // 10, op % 10,
                                   direction) + alternative
def getPiconName(serviceRef):
	service = eServiceReference(serviceRef)
	if service.getPath().startswith("/") and serviceRef.startswith("1:"):
		info = eServiceCenter.getInstance().info(eServiceReference(serviceRef))
		refstr = info and info.getInfoString(service, iServiceInformation.sServiceref)
		serviceRef = refstr and eServiceReference(refstr).toCompareString()
	#remove the path and name fields, and replace ':' by '_'
	fields = GetWithAlternative(serviceRef).split(':', 10)[:10]
	if not fields or len(fields) < 10:
		return ""
	pngname = findPicon('_'.join(fields))
	if not pngname and not fields[6].endswith("0000"):
		#remove "sub-network" from namespace
		fields[6] = fields[6][:-4] + "0000"
		pngname = findPicon('_'.join(fields))
	if not pngname and fields[0] != '1':
		#fallback to 1 for IPTV streams
		fields[0] = '1'
		pngname = findPicon('_'.join(fields))
	if not pngname and fields[2] != '2':
		#fallback to 1 for TV services with non-standard service types
		fields[2] = '1'
		pngname = findPicon('_'.join(fields))
	if not pngname: # picon by channel name
		name = ServiceReference(serviceRef).getServiceName()
		name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
		name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
		if name:
			pngname = findPicon(name)
			if not pngname and len(name) > 2 and name.endswith('hd'):
				pngname = findPicon(name[:-2])
			if not pngname and len(name) > 6:
				series = re.sub(r's[0-9]*e[0-9]*$', '', name)
				pngname = findPicon(series)
	return pngname
Example #10
0
 def getOrbitalPos(self, ref):
     refstr = None
     if hasattr(ref, 'sref'):
         refstr = str(ref.sref)
     else:
         refstr = str(ref)
     refstr = refstr and GetWithAlternative(refstr)
     refparts = refstr.split(':')
     if '%3a//' in refparts[10]:
         return "%s" % _("Stream")
     reftype = int(refparts[0] or "0")
     flags = int(refparts[1] or "0")
     stype = int(refparts[2] or "0", 16)
     if reftype == eServiceReference.idServiceHDMIIn and flags == eServiceReference.noFlags and stype == eServiceReferenceDVB.dTv:
         return _("HDMI IN")
     op = int(refparts[6][:-4] or "0", 16)
     if op == 0xeeee:
         return "%s" % _("DVB-T")
     if op == 0xffff:
         return "%s" % _("DVB-C")
     direction = 'E'
     if op > 1800:
         op = 3600 - op
         direction = 'W'
     return ("%d.%d\xc2\xb0%s") % (op // 10, op % 10, direction)
Example #11
0
def getLcdPiconName(serviceName):
    #remove the path and name fields, and replace ':' by '_'
    sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
    pngname = findLcdPicon(sname)
    if not pngname:
        fields = sname.split('_', 3)
        if len(fields) > 2 and fields[
                2] != '1':  #fallback to 1 for services with different service types
            fields[2] = '1'
        if len(fields
               ) > 0 and fields[0] != '1':  #fallback to 1 for IPTV streams
            fields[0] = '1'
        pngname = findLcdPicon('_'.join(fields))
    if not pngname:  # picon by channel name
        name = ServiceReference(serviceName).getServiceName()
        if six.PY3:
            name = unicodedata.normalize('NFKD', name)
        else:
            name = unicodedata.normalize(
                'NFKD',
                six.text_type(name, 'utf_8',
                              errors='ignore')).encode('ASCII', 'ignore')
        name = re.sub(
            '[^a-z0-9]', '',
            name.replace('&', 'and').replace('+',
                                             'plus').replace('*',
                                                             'star').lower())
        if len(name) > 0:
            pngname = findLcdPicon(name)
            if not pngname and len(name) > 2 and name.endswith('hd'):
                pngname = findLcdPicon(name[:-2])
    return pngname
Example #12
0
def getPiconName(serviceName):
    #remove the path and name fields, and replace ':' by '_'
    name = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
    pngname = findPicon(name)
    if not pngname:
        fields = name.split('_', 3)
        if len(fields) > 2:
            if fields[0] != '1':
                #fallback to 1 for other reftypes
                fields[0] = '1'
                pngname = findPicon('_'.join(fields))
            if not pngname and fields[2] != '2':
                #fallback to 1 for tv services with nonstandard servicetypes
                fields[2] = '1'
                pngname = findPicon('_'.join(fields))
    if not pngname:  # picon by channel name
        name = ServiceReference(serviceName).getServiceName()
        name = unicodedata.normalize('NFKD',
                                     unicode(name, 'utf_8',
                                             errors='ignore')).encode(
                                                 'ASCII', 'ignore')
        name = re.sub(
            '[^a-z0-9]', '',
            name.replace('&', 'and').replace('+',
                                             'plus').replace('*',
                                                             'star').lower())
        if name:
            pngname = findPicon(name)
            if not pngname and len(name) > 2 and name.endswith('hd'):
                pngname = findPicon(name[:-2])
    return pngname
Example #13
0
	def changed(self, what):
		if self.instance:
			pngname = ""
			if what[0] != self.CHANGED_CLEAR:
				sname = self.source.text
				if sname.startswith("1:134"):
					sname = GetWithAlternative(self.source.text)
				pos = sname.rfind(':http')
				if pos != -1:
					sname = sname.split('http')[0]
				# strip all after last :
				pos = sname.rfind(':')
				if pos != -1:
					sname = sname[:pos].rstrip(':').replace(':','_')
				pngname = self.nameCache.get(sname, "")
				if pngname == "":
					pngname = self.findPicon(sname)
					if pngname != "":
						self.nameCache[sname] = pngname
			if pngname == "": # no XPicons for service found
				self.instance.hide()
			else:
				self.instance.show()
			if pngname != "" and self.pngname != pngname:
				self.instance.setPixmapFromFile(pngname)
				self.pngname = pngname
Example #14
0
def getPiconName(serviceName):
	#remove the path and name fields, and replace ':' by '_'
	sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
	pngname = findPicon(sname)
	if not pngname:
		fields = sname.split('_', 3)
		if len(fields) > 2 and fields[2] != '2':
			#fallback to 1 for tv services with nonstandard servicetypes
			fields[2] = '1'
			pngname = findPicon('_'.join(fields))
	if not pngname: # picon by channel name
		name = ServiceReference(serviceName).getServiceName()
		name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
		name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
		if name:
			pngname = findPicon(name)
			if not pngname and len(name) > 2 and name.endswith('hd'):
				pngname = findPicon(name[:-2])
	if not pngname:
		tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png")
		if pathExists(tmp):
			pngname = tmp
		else:
			pngname = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/picon_default.png")
	return pngname
Example #15
0
def getPiconName(serviceName):
	sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
	pngname = findPicon(sname)
	if not pngname: # picon by channel name
		name = ServiceReference(serviceName).getServiceName()
		name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
		name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
		if len(name) > 0:
			pngname = findPicon(name)
			if not pngname and len(name) > 2 and name.endswith('hd'):
				pngname = findPicon(name[:-2])
	if not pngname:
		fields = sname.split('_', 3)
		if len(fields) > 0 and fields[0] != '1':
			fields[0] = '1'
		pngname = findPicon('_'.join(fields))
		if len(fields) > 2:
			while not pngname:
				tmp = ''
				for i in range(256):
					tmp = hex(i)[2:].upper().zfill(2)
					fields[2] = tmp
					pngname = findPicon('_'.join(fields))
					if pngname:
						newpng = '/usr/share/enigma2/picon/' + name + '.png'
						try:
							os.symlink(pngname, newpng)
						except:
							pass
						break
				if tmp == "FF":
					break
	return pngname
Example #16
0
def findPicon(service):
    pngname = ""
    sname = service
    s_name = sname
    if sname.startswith("1:134"):
        sname = GetWithAlternative(service)
    for protocol in ("http", "rtmp", "rtsp", "mms", "rtp"):
        pos = sname.rfind(':' + protocol)
        if pos != -1:
            sname = sname.split(protocol)[0]
            break
    pos = sname.rfind(':')
    if pos != -1:
        sname = sname[:pos].rstrip(':').replace(':', '_')
    pngname = nameCache.get(sname, "")
    if pngname == "":
        pngname = findFile(sname)
        if pngname == "":
            serviceHandler = eServiceCenter.getInstance()
            service = eServiceReference(s_name)
            if service and service is not None:
                info = serviceHandler.info(service)
                if info and info is not None:
                    service_name = info.getName(service).replace(
                        '\xc2\x86', '').replace('\xc2\x87',
                                                '').replace('/', '_')
                    print service_name
                    pngname = findFile(service_name)
        if pngname == "" and sname.startswith("4097_"):
            pngname = findFile(sname.replace("4097_", "1_", 1))
        if pngname != "":
            nameCache[sname] = pngname
    return pngname
Example #17
0
def getPiconName(serviceName):
    sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
    pngname = findPicon(sname)
    if not pngname:
        fields = sname.split('_', 3)
        if len(fields) > 2 and fields[2] != '1':
            fields[2] = '1'
        if len(fields) > 0 and fields[0] != '1':
            fields[0] = '1'
        pngname = findPicon('_'.join(fields))
    if not pngname:
        name = ServiceReference(serviceName).getServiceName()
        name = unicodedata.normalize('NFKD',
                                     unicode(name, 'utf_8',
                                             errors='ignore')).encode(
                                                 'ASCII', 'ignore')
        name = re.sub(
            '[^a-z0-9]', '',
            name.replace('&', 'and').replace('+',
                                             'plus').replace('*',
                                                             'star').lower())
        if len(name) > 0:
            pngname = findPicon(name)
            if not pngname and len(name) > 2 and name.endswith('hd'):
                pngname = findPicon(name[:-2])
    return pngname
Example #18
0
def getPiconName(serviceName):
	sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
	pngname = findPicon(sname)
	if not pngname:
		fields = sname.split('_', 3)
		if len(fields) > 0 and fields[0] != '1':
			fields[0] = '1'
		pngname = findPicon('_'.join(fields))
	return pngname
 def changed(self, what):
     if self.instance:
         pngname = ""
         if what[0] != self.CHANGED_CLEAR:
             sname = self.source.text
             pos = sname.rfind(':http')
             sname = sname.split('http')[0]
             s_name = sname
             if sname.startswith("1:134"):
                 sname = GetWithAlternative(self.source.text)
             if sname.startswith("4097:0"):
                 sname = self.source.text
                 pos = sname.rfind(':http')
                 if pos != -1:
                     sname = sname.split('http')[0]
                 pos = sname.rfind(':rtmp')
                 if pos != -1:
                     sname = sname.split('rtmp')[0]
                 pos = sname.rfind(':rtsp')
                 if pos != -1:
                     sname = sname.split('rtsp')[0]
                 pos = sname.rfind(':rtp')
                 if pos != -1:
                     sname = sname.split('rtp')[0]
                 pos = sname.rfind(':mms')
                 if pos != -1:
                     sname = sname.split('mms')[0]
             pos = sname.rfind(':')
             if pos != -1:
                 sname = sname[:pos].rstrip(':').replace(':', '_')
             pngname = self.nameCache.get(sname, "")
             if pngname == "":
                 pngname = self.findPicon(sname)
                 if pngname == "":
                     serviceHandler = eServiceCenter.getInstance()
                     service = eServiceReference(s_name)
                     if service and service is not None:
                         info = serviceHandler.info(service)
                         if info and info is not None:
                             service_name = info.getName(service).replace(
                                 '\xc2\x86',
                                 '').replace('\xc2\x87',
                                             '').replace('/', '_')
                             pngname = self.findPicon(service_name)
                 if pngname != "":
                     self.nameCache[sname] = pngname
         if pngname == "":  # no picon for service found
             self.instance.hide()
         else:
             self.instance.show()
         if pngname != "" and self.pngname != pngname:
             if config.usage.picon_scale.value:
                 self.instance.setScale(2)
             else:
                 self.instance.setScale(0)
             self.instance.setPixmapFromFile(pngname)
             self.pngname = pngname
Example #20
0
 def getPiconName(self, serviceName):
     #remove the path and name fields, and replace ':' by '_'
     fields = GetWithAlternative(serviceName).split(':', 10)[:10]
     if not fields or len(fields) < 10:
         return ""
     pngname = self.findPicon('_'.join(fields))
     if not pngname and not fields[6].endswith("0000"):
         #remove "sub-network" from namespace
         fields[6] = fields[6][:-4] + "0000"
         pngname = self.findPicon('_'.join(fields))
     if not pngname and fields[0] != '1':
         #fallback to 1 for IPTV streams
         fields[0] = '1'
         pngname = self.findPicon('_'.join(fields))
     if not pngname and fields[2] != '2':
         #fallback to 1 for TV services with non-standard service types
         fields[2] = '1'
         pngname = self.findPicon('_'.join(fields))
     if not pngname:  # picon by channel name
         name = ServiceReference(serviceName).getServiceName()
         if PY2:
             name = unicodedata.normalize(
                 'NFKD',
                 unicode(name, 'utf_8',
                         errors='ignore')).encode('ASCII', 'ignore')
         else:
             name = unicodedata.normalize('NFKD', str(name)).encode(
                 'ASCII', 'ignore').decode('ASCII', 'ignore')
         name = re.sub(
             '[^a-z0-9]', '',
             name.replace('&',
                          'and').replace('+',
                                         'plus').replace('*',
                                                         'star').lower())
         if len(name) > 0:
             pngname = self.findPicon(name)
             if not pngname and len(name) > 2 and name.endswith('hd'):
                 pngname = self.findPicon(name[:-2])
             if not pngname and len(name) > 6:
                 series = re.sub(r's[0-9]*e[0-9]*$', '', name)
                 pngname = self.findPicon(series)
     if not pngname:  # picon default
         tmp = resolveFilename(
             SCOPE_GUISKIN,
             'picon_default.png')  # picon_default in current active skin
         tmp2 = self.findPicon(
             "picon_default")  # picon_default in picon folder
         if pathExists(tmp2):
             pngname = tmp2
         else:
             if pathExists(tmp):
                 pngname = tmp
             else:
                 pngname = resolveFilename(SCOPE_GUISKIN,
                                           'picon_default.png')
     return pngname
Example #21
0
def getLcdPiconName(serviceName):
    #remove the path and name fields, and replace ':' by '_'
    sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
    pngname = findLcdPicon(sname)
    if not pngname:
        fields = sname.split('_', 3)
        if len(fields) > 2 and fields[2] != '2':
            #fallback to 1 for tv services with nonstandard servicetypes
            fields[2] = '1'
            pngname = findLcdPicon('_'.join(fields))
    return pngname
def getDataFromDatabase(service,
                        eventid,
                        logger,
                        logPrefix="",
                        beginTime=None,
                        EventName=None):
    try:
        from Plugins.Extensions.EpgShare.main import getEPGDB
        data = None
        if "::" in str(service):
            service = service.split("::")[0] + ":"
        if "http" in str(service):
            service = service.split("http")[0]

        # Bug Fix, if channel has alternatives
        if str(service).startswith("1:134"):
            service = GetWithAlternative(str(service))

        if not "1:0:0:0:0:0:0:0:0:0:" in service and not "4097:0:0:0:0:0:0:0:0:0:" in service:
            if beginTime and EventName:
                queryPara = "ref: %s, eventId: %s, title:: %s, beginTime: %s" % (
                    str(service), str(eventid), str(
                        EventName.lower()).decode("utf-8"), str(
                            int(beginTime)))
                logger.debug("%sgetDataFromDatabase: %s", logPrefix, queryPara)

                data = getEPGDB().selectSQL(
                    "SELECT * FROM epg_extradata WHERE ref = ? AND (eventid = ? or (LOWER(title) = ? and airtime BETWEEN ? AND ?))",
                    [
                        str(service),
                        str(eventid),
                        str(EventName.lower()).decode("utf-8"),
                        str(int(beginTime) - 120),
                        str(int(beginTime) + 120)
                    ])
            else:
                queryPara = "ref: %s, eventId: %s" % (str(service),
                                                      str(eventid))
                logger.debug("%sgetDataFromDatabase: %s", logPrefix, queryPara)

                data = getEPGDB().selectSQL(
                    "SELECT * FROM epg_extradata WHERE ref = ? AND eventid = ?",
                    [str(service), str(eventid)])
            if data and len(data) > 0:
                return data[0]
            else:
                return None
        else:
            return None
    except Exception as ex:
        logger.exception("%sgetDataFromDatabase: %s", logPrefix, str(ex))
        return None
def getPicon(sname):
    sname = GetWithAlternative(sname)
    if sname is not None:
        pos = sname.rfind(':')
    else:
        return "/images/default_picon.png"

    if pos != -1:
        sname = sname[:pos].rstrip(':').replace(':', '_') + ".png"
    filename = getPiconPath() + sname
    if fileExists(filename):
        return "/picon/" + sname
    return "/images/default_picon.png"
Example #24
0
def findPicon(service):
    pngname = ""
    sname = service
    if sname.startswith("1:134"):
        sname = GetWithAlternative(service)
    pos = sname.rfind(':http')
    if pos != -1:
        sname = sname.split('http')[0]
    pos = sname.rfind(':')
    if pos != -1:
        sname = sname[:pos].rstrip(':').replace(':', '_')
    pngname = nameCache.get(sname, "")
    if pngname == "":
        pngname = findFile(sname)
        if pngname != "":
            nameCache[sname] = pngname
    return pngname
Example #25
0
    def changed(self, what):
        if self.instance:
            pngname = ''
            if what[0] != self.CHANGED_CLEAR:
                sname = self.source.text
                s_name = sname
                if sname.startswith('1:134'):
                    sname = GetWithAlternative(self.source.text)
                for protocol in ('http', 'rtmp', 'rtsp', 'mms', 'rtp'):
                    pos = sname.rfind(':' + protocol)
                    if pos != -1:
                        sname = sname.split(protocol)[0]
                        break

                pos = sname.rfind(':')
                if pos != -1:
                    sname = sname[:pos].rstrip(':').replace(':', '_')
                pngname = self.nameCache.get(sname, '')
                if pngname == '':
                    pngname = self.findPicon(sname)
                    if pngname == '':
                        serviceHandler = eServiceCenter.getInstance()
                        service = eServiceReference(s_name)
                        if service and service is not None:
                            info = serviceHandler.info(service)
                            if info and info is not None:
                                service_name = info.getName(service).replace(
                                    '\xc2\x86',
                                    '').replace('\xc2\x87',
                                                '').replace('/', '_')
                                pngname = self.findPicon(service_name)
                    if pngname == '' and sname.startswith('4097_'):
                        pngname = self.findPicon(
                            sname.replace('4097_', '1_', 1))
                    if pngname != '':
                        self.nameCache[sname] = pngname
            if pngname == '':
                self.instance.hide()
            else:
                self.instance.show()
            if pngname != '' and self.pngname != pngname:
                self.instance.setScale(2)
                self.instance.setPixmapFromFile(pngname)
                self.pngname = pngname
Example #26
0
 def getOrbitalPos(self, ref):
     refstr = None
     if hasattr(ref, 'sref'):
         refstr = str(ref.sref)
     else:
         refstr = str(ref)
     refstr = refstr and GetWithAlternative(refstr)
     if '%3a//' in refstr:
         return '%s' % _('Stream')
     op = int(refstr.split(':', 10)[6][:-4] or '0', 16)
     if op == 61166:
         return '%s' % _('DVB-T')
     if op == 65535:
         return '%s' % _('DVB-C')
     direction = 'E'
     if op > 1800:
         op = 3600 - op
         direction = 'W'
     return '%d.%d\xc2\xb0%s' % (op // 10, op % 10, direction)
Example #27
0
	def getOrbitalPos(self, ref):
		refstr = ''
		if hasattr(ref, 'sref'):
			refstr = str(ref.sref)
		else:
			refstr = str(ref)
		refstr = refstr and GetWithAlternative(refstr)
		if '%3a//' in refstr:
			return "%s" % _("Stream")
		op = int(refstr.split(':', 10)[6][:-4] or "0",16)
		if op == 0xeeee:
			return "%s" % _("DVB-T")
		if op == 0xffff:
			return "%s" % _("DVB-C")
		direction = 'E'
		if op > 1800:
			op = 3600 - op
			direction = 'W'
		return ("%d.%d\xc2\xb0%s") % (op // 10, op % 10, direction)
Example #28
0
 def getOrbitalPos(self, ref):
     refstr = None
     if hasattr(ref, "sref"):
         refstr = str(ref.sref)
     else:
         refstr = str(ref)
     refstr = refstr and GetWithAlternative(refstr)
     if "%3a//" in refstr:
         return "%s" % _("Stream")
     op = int(refstr.split(":", 10)[6][:-4] or "0", 16)
     if op == 0xeeee:
         return "%s" % _("DVB-T")
     if op == 0xffff:
         return "%s" % _("DVB-C")
     direction = "E"
     if op > 1800:
         op = 3600 - op
         direction = "W"
     return ("%d.%d\xc2\xb0%s") % (op // 10, op % 10, direction)
Example #29
0
def getPiconName(serviceName):
	#remove the path and name fields, and replace ':' by '_'
	fields = GetWithAlternative(serviceName).split(':', 10)[:10]
	if not fields or len(fields) < 10:
		return ""
	pngname = findPicon('_'.join(fields))
	if not pngname and not fields[6].endswith("0000"):
		#remove "sub-network" from namespace
		fields[6] = fields[6][:-4] + "0000"
		pngname = findPicon('_'.join(fields))
	if not pngname and fields[0] != '1':
		#fallback to 1 for other reftypes
		fields[0] = '1'
		pngname = findPicon('_'.join(fields))
	if not pngname and fields[2] != '1':
		#fallback to 1 for services with different service types
		fields[2] = '1'
		pngname = findPicon('_'.join(fields))
	if not pngname: # picon by channel name
		name = ServiceReference(serviceName).getServiceName()
		name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
		name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
		if name:
			pngname = findPicon(name)
			if not pngname and len(name) > 2 and name.endswith('hd'):
				pngname = findPicon(name[:-2])
	if not pngname:
           tmp = resolveFilename(SCOPE_CURRENT_SKIN, 'picon_default.png')
           tmp2 = findPicon("picon_default")
           if pathExists(tmp2):
              pngname = tmp2
           else:
              if pathExists(tmp):
                 pngname = tmp
              else:
                 pngname = resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/picon_default.png')
        return pngname
Example #30
0
def getPiconLName(serviceName):
	#remove the path and name fields, and replace ':' by '_'
	sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
	pngname = findPiconL(sname)
	if not pngname:
		fields = sname.split('_', 3)
		if len(fields) > 2 and fields[2] != '2':
			#fallback to 1 for tv services with nonstandard servicetypes
			fields[2] = '1'
			pngname = findPiconL('_'.join(fields))
	if not pngname: # picon by channel name
		name = ServiceReference(serviceName).getServiceName()
		name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
		excludeChars = ['/', '\\', '\'', '"', '`', '?', ' ', '(', ')', ':', '<', '>', '|', '.', '\n']
		name = re.sub('[%s]' % ''.join(excludeChars), '', name)
		name = name.replace('&', 'and')
		name = name.replace('+', 'plus')
		name = name.replace('*', 'star')
		name = name.lower()
		if len(name) > 0:
			pngname = findPicon(name)
			if not pngname and len(name) > 2 and name.endswith('hd'):
				pngname = findPicon(name[:-2])
	return pngname