Exemplo n.º 1
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 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
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
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)):
						if config.plugins.epgsearch.favorit_name.value:
							usr_ref_list.append(service.toString())
						else:
							usr_ref_list.append(':'.join(service.toString().split(':')[:11]))
		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:
						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)):
									refstr = service.toString()
									if refstr.startswith('1:134:'):
										refstr = GetWithAlternative(refstr)
									if config.plugins.epgsearch.favorit_name.value:
										usr_ref_list.append(refstr)
									else:
										usr_ref_list.append(':'.join(refstr.split(':')[:11]))
		result = [ ]
		if config.plugins.epgsearch.favorit_name.value:
			for e in epglist:
				for x in usr_ref_list:
					y = ':'.join(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:
				if e[0] in usr_ref_list:
					result.append(e)
		return result
Exemplo n.º 6
0
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"
Exemplo n.º 7
0
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"
Exemplo n.º 8
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
Exemplo n.º 9
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
Exemplo n.º 10
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
Exemplo n.º 11
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)
Exemplo n.º 12
0
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
Exemplo n.º 13
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
Exemplo n.º 14
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
Exemplo n.º 15
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
Exemplo n.º 16
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
Exemplo n.º 17
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
Exemplo n.º 18
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
Exemplo n.º 19
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
Exemplo n.º 20
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
Exemplo n.º 21
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
Exemplo n.º 22
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
Exemplo n.º 23
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
Exemplo n.º 24
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
Exemplo n.º 25
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
Exemplo n.º 26
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
Exemplo n.º 27
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
Exemplo n.º 28
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
Exemplo n.º 29
0
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
Exemplo n.º 30
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)
Exemplo n.º 31
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)
Exemplo n.º 32
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)
Exemplo n.º 33
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
Exemplo n.º 34
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
Exemplo n.º 35
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
Exemplo n.º 36
0
    def keyGo(self, result=None):
        if not self.timerentry_service_ref.isRecordable():
            self.session.openWithCallback(
                self.selectChannelSelector, MessageBox,
                _("You didn't select a channel to record from."),
                MessageBox.TYPE_ERROR)
        elif self.timerentry_remote.value:
            service_ref = self.timerentry_service_ref
            if self.timer.eit is not None:
                event = eEPGCache.getInstance().lookupEventId(
                    service_ref.ref, self.timer.eit)
                if event:
                    n = event.getNumOfLinkageServices()
                    if n > 1:
                        tlist = []
                        ref = self.session.nav.getCurrentlyPlayingServiceReference(
                        )
                        parent = service_ref.ref
                        selection = 0
                        for x in range(n):
                            i = event.getLinkageService(parent, x)
                            if i.toString() == ref.toString():
                                selection = x
                            tlist.append((i.getName(), i))
                        self.session.openWithCallback(
                            self.RemoteSubserviceSelected,
                            ChoiceBox,
                            title=_("Please select a subservice to record..."),
                            list=tlist,
                            selection=selection)
                        return
                    elif n > 0:
                        parent = service_ref.ref
                        service_ref = ServiceReference(
                            event.getLinkageService(parent, 0))
            #resolve alternative
            alternative_ref = GetWithAlternative(str(service_ref))
            service_ref = ':'.join(alternative_ref.split(':')[:11])

            # XXX: this will - without any hassle - ignore the value of repeated
            begin, end = self.getBeginEnd()

            # when a timer end is set before the start, add 1 day
            if end < begin:
                end += 86400

            rt_name = urllib.quote(
                self.timerentry_name.value.decode('utf8').encode(
                    'utf8', 'ignore'))
            rt_description = urllib.quote(
                self.timerentry_description.value.decode('utf8').encode(
                    'utf8', 'ignore'))
            rt_disabled = 0  # XXX: do we really want to hardcode this? why do we offer this option then?
            rt_repeated = 0  # XXX: same here
            rt_dirname = "/hdd/movie"

            if self.timerentry_justplay.value == "zap":
                rt_justplay = 1
            else:
                rt_justplay = 0

            rt_eit = 0
            if self.timer.eit is not None:
                rt_eit = self.timer.eit

            rt_afterEvent = {
                "deepstandby": AFTEREVENT.DEEPSTANDBY,
                "standby": AFTEREVENT.STANDBY,
                "nothing": AFTEREVENT.NONE,
                "auto": AFTEREVENT.AUTO
            }.get(self.timerentry_afterevent.value, AFTEREVENT.AUTO)

            url = "%s/web/timeradd?sRef=%s&begin=%s&end=%s&name=%s&description=%s&disabled=%s&justplay=%s&afterevent=%s&repeated=%s&dirname=%s&eit=%s" % (
                config.usage.remote_fallback.value.rsplit(":", 1)[0],
                service_ref, begin, end, rt_name, rt_description, rt_disabled,
                rt_justplay, rt_afterEvent, rt_repeated, rt_dirname, rt_eit)
            print "[RemoteTimer] debug remote", url
            from Screens.TimerEdit import getUrl
            getUrl(url).addCallback(self.remoteTimerOK).addErrback(
                self.remoteTimerNOK)

        else:

            self.timer.name = self.timerentry_name.value
            self.timer.description = self.timerentry_description.value
            self.timer.justplay = self.timerentry_justplay.value == "zap"
            self.timer.always_zap = self.timerentry_justplay.value == "zap+record"
            self.timer.zap_wakeup = self.timerentry_zapwakeup.value
            self.timer.pipzap = self.timerentry_pipzap.value
            self.timer.rename_repeat = self.timerentry_renamerepeat.value
            self.timer.conflict_detection = self.timerentry_conflictdetection.value
            if self.timerentry_justplay.value == "zap":
                if not self.timerentry_showendtime.value:
                    self.timerentry_endtime.value = self.timerentry_starttime.value
                    self.timerentry_afterevent.value = "nothing"
            self.timer.resetRepeated()
            self.timer.afterEvent = {
                "nothing": AFTEREVENT.NONE,
                "deepstandby": AFTEREVENT.DEEPSTANDBY,
                "standby": AFTEREVENT.STANDBY,
                "auto": AFTEREVENT.AUTO
            }[self.timerentry_afterevent.value]
            self.timer.descramble = {
                "normal": True,
                "descrambled+ecm": True,
                "scrambled+ecm": False,
            }[self.timerentry_recordingtype.value]
            self.timer.record_ecm = {
                "normal": False,
                "descrambled+ecm": True,
                "scrambled+ecm": True,
            }[self.timerentry_recordingtype.value]
            self.timer.service_ref = self.timerentry_service_ref
            self.timer.tags = self.timerentry_tags

            if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath(
            ):
                self.timer.dirname = self.timerentry_dirname.value
                config.movielist.last_timer_videodir.value = self.timer.dirname
                config.movielist.last_timer_videodir.save()

            if self.timerentry_type.value == "once":
                self.timer.begin, self.timer.end = self.getBeginEnd()
            if self.timerentry_type.value == "repeated":
                if self.timerentry_repeated.value == "daily":
                    for x in (0, 1, 2, 3, 4, 5, 6):
                        self.timer.setRepeated(x)

                if self.timerentry_repeated.value == "weekly":
                    self.timer.setRepeated(self.timerentry_weekday.index)

                if self.timerentry_repeated.value == "weekdays":
                    for x in (0, 1, 2, 3, 4):
                        self.timer.setRepeated(x)

                if self.timerentry_repeated.value == "user":
                    for x in (0, 1, 2, 3, 4, 5, 6):
                        if self.timerentry_day[x].value:
                            self.timer.setRepeated(x)

                self.timer.repeatedbegindate = self.getTimestamp(
                    self.timerentry_repeatedbegindate.value,
                    self.timerentry_starttime.value)
                if self.timer.repeated:
                    self.timer.begin = self.getTimestamp(
                        self.timerentry_repeatedbegindate.value,
                        self.timerentry_starttime.value)
                    self.timer.end = self.getTimestamp(
                        self.timerentry_repeatedbegindate.value,
                        self.timerentry_endtime.value)
                else:
                    self.timer.begin = self.getTimestamp(
                        time(), self.timerentry_starttime.value)
                    self.timer.end = self.getTimestamp(
                        time(), self.timerentry_endtime.value)

                # when a timer end is set before the start, add 1 day
                if self.timer.end < self.timer.begin:
                    self.timer.end += 86400

            if self.timer.eit is not None:
                event = eEPGCache.getInstance().lookupEventId(
                    self.timer.service_ref.ref, self.timer.eit)
                if event:
                    n = event.getNumOfLinkageServices()
                    if n > 1:
                        tlist = []
                        ref = self.session.nav.getCurrentlyPlayingServiceOrGroup(
                        )
                        parent = self.timer.service_ref.ref
                        selection = 0
                        for x in range(n):
                            i = event.getLinkageService(parent, x)
                            if i.toString() == ref.toString():
                                selection = x
                            tlist.append((i.getName(), i))
                        self.session.openWithCallback(
                            self.subserviceSelected,
                            ChoiceBox,
                            title=_("Please select a subservice to record..."),
                            list=tlist,
                            selection=selection)
                        return
                    elif n > 0:
                        parent = self.timer.service_ref.ref
                        self.timer.service_ref = ServiceReference(
                            event.getLinkageService(parent, 0))
            self.saveTimer()
            self.close((True, self.timer))