def ResolveCiAlternative(ref): serviceList = self.ServiceHandler and self.ServiceHandler.list( ref) if serviceList: for service in serviceList.getContent("R"): if isPlayableForCur(service): return service return None
def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust=True): oldref = self.currentlyPlayingServiceOrGroup if ref and oldref and ref == oldref and not forceRestart: print("[Navigation] ignore request to play already running service(1)") return 1 print("[Navigation] playing", ref and ref.toString()) if path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.value == '1': try: if '0:0:0:0:0:0:0:0:0' not in ref.toString(): signal = 1 else: signal = 0 open("/proc/stb/lcd/symbol_signal", "w").write(str(signal)) except: open("/proc/stb/lcd/symbol_signal", "w").write("0") elif path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.value == '0': open("/proc/stb/lcd/symbol_signal", "w").write("0") if ref is None: self.stopService() return 0 from Components.ServiceEventTracker import InfoBarCount InfoBarInstance = InfoBarCount == 1 and InfoBar.instance if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl=False, forceRestart=forceRestart, adjust=adjust)): if ref.flags & eServiceReference.isGroup: oldref = self.currentlyPlayingServiceReference or eServiceReference() playref = getBestPlayableServiceReference(ref, oldref) if playref and config.misc.use_ci_assignment.value and not isPlayableForCur(playref): alternative_ci_ref = ResolveCiAlternative(ref, playref) if alternative_ci_ref: playref = alternative_ci_ref print("[Navigation] alternative ref: ", playref and playref.toString()) if playref and oldref and playref == oldref and not forceRestart: print("[Navigation] ignore request to play already running service(2)") return 1 if not playref: alternativeref = getBestPlayableServiceReference(ref, eServiceReference(), True) self.stopService() if alternativeref and self.pnav: self.currentlyPlayingServiceReference = alternativeref self.currentlyPlayingServiceOrGroup = ref if self.pnav.playService(alternativeref): print("[Navigation] Failed to start: ", alternativeref.toString()) self.currentlyPlayingServiceReference = None self.currentlyPlayingServiceOrGroup = None return 0 elif checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False)): if self.currentlyPlayingServiceOrGroup and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(self.currentlyPlayingServiceOrGroup, adjust): self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent() return 1 else: playref = ref if self.pnav: self.pnav.stopService() self.currentlyPlayingServiceReference = playref self.currentlyPlayingServiceOrGroup = ref if InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(ref, adjust): self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent() setPriorityFrontend = False if SystemInfo["DVB-T_priority_tuner_available"] or SystemInfo["DVB-C_priority_tuner_available"] or SystemInfo["DVB-S_priority_tuner_available"] or SystemInfo["ATSC_priority_tuner_available"]: str_service = playref.toString() if '%3a//' not in str_service and not str_service.rsplit(":", 1)[1].startswith("/"): type_service = playref.getUnsignedData(4) >> 16 if type_service == 0xEEEE: if SystemInfo["DVB-T_priority_tuner_available"] and config.usage.frontend_priority_dvbt.value != "-2": if config.usage.frontend_priority_dvbt.value != config.usage.frontend_priority.value: setPreferredTuner(int(config.usage.frontend_priority_dvbt.value)) setPriorityFrontend = True if SystemInfo["ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2": if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value: setPreferredTuner(int(config.usage.frontend_priority_atsc.value)) setPriorityFrontend = True elif type_service == 0xFFFF: if SystemInfo["DVB-C_priority_tuner_available"] and config.usage.frontend_priority_dvbc.value != "-2": if config.usage.frontend_priority_dvbc.value != config.usage.frontend_priority.value: setPreferredTuner(int(config.usage.frontend_priority_dvbc.value)) setPriorityFrontend = True if SystemInfo["ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2": if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value: setPreferredTuner(int(config.usage.frontend_priority_atsc.value)) setPriorityFrontend = True else: if SystemInfo["DVB-S_priority_tuner_available"] and config.usage.frontend_priority_dvbs.value != "-2": if config.usage.frontend_priority_dvbs.value != config.usage.frontend_priority.value: setPreferredTuner(int(config.usage.frontend_priority_dvbs.value)) setPriorityFrontend = True if self.pnav.playService(playref): print("[Navigation] Failed to start: ", playref.toString()) self.currentlyPlayingServiceReference = None self.currentlyPlayingServiceOrGroup = None if setPriorityFrontend: setPreferredTuner(int(config.usage.frontend_priority.value)) return 0 elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(oldref, adjust): self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent() return 1
def buildEntry(self, service, service_name, events, picon): r1 = self.service_rect r2 = self.event_rect selected = self.cur_service[0] == service # Picon and Service name if CompareWithAlternatives(service, self.currentlyPlaying and self.currentlyPlaying.toString()): serviceForeColor = self.foreColorServiceSelected serviceBackColor = self.backColorServiceSelected bgpng = self.curSerPix or self.nowEvPix currentservice = True else: serviceForeColor = self.foreColorService serviceBackColor = self.backColorService bgpng = self.othEvPix currentservice = False res = [ None ] if bgpng is not None: # bacground for service rect res.append(MultiContentEntryPixmapAlphaTest( pos = (r1.x + self.serviceBorderWidth, r1.y + self.serviceBorderWidth), size = (r1.w - 2 * self.serviceBorderWidth, r1.h - 2 * self.serviceBorderWidth), png = bgpng, flags = BT_SCALE)) else: res.append(MultiContentEntryText( pos = (r1.x, r1.y), size = (r1.w, r1.h), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_CENTER, text = "", color = serviceForeColor, color_sel = serviceForeColor, backcolor = serviceBackColor, backcolor_sel = serviceBackColor)) displayPicon = None if self.showPicon: if picon is None: # go find picon and cache its location picon = getPiconName(service) curIdx = self.l.getCurrentSelectionIndex() self.list[curIdx] = (service, service_name, events, picon) piconWidth = self.picon_size.width() piconHeight = self.picon_size.height() if picon != "": displayPicon = loadPNG(picon) if displayPicon is not None: res.append(MultiContentEntryPixmapAlphaTest( pos = (r1.x + self.serviceBorderWidth, r1.y + self.serviceBorderWidth), size = (piconWidth, piconHeight), png = displayPicon, backcolor = None, backcolor_sel = None, flags = BT_SCALE | BT_KEEP_ASPECT_RATIO)) elif not self.showServiceTitle: # no picon so show servicename anyway in picon space namefont = 1 namefontflag = int(config.misc.graph_mepg.servicename_alignment.value) namewidth = piconWidth piconWidth = 0 else: piconWidth = 0 if self.showServiceTitle: # we have more space so reset parms namefont = 0 namefontflag = int(config.misc.graph_mepg.servicename_alignment.value) namewidth = r1.w - piconWidth if self.showServiceTitle or displayPicon is None: res.append(MultiContentEntryText( pos = (r1.x + piconWidth + self.serviceBorderWidth + self.serviceNamePadding, r1.y + self.serviceBorderWidth), size = (namewidth - 2 * (self.serviceBorderWidth + self.serviceNamePadding), r1.h - 2 * self.serviceBorderWidth), font = namefont, flags = namefontflag, text = service_name, color = serviceForeColor, color_sel = serviceForeColor, backcolor = None, backcolor_sel = None)) # Events for service backColorSel = self.backColorSelected if events: start = self.time_base + self.offs * self.time_epoch * 60 end = start + self.time_epoch * 60 left = r2.x top = r2.y width = r2.w height = r2.h now = time() for ev in events: #(event_id, event_title, begin_time, duration) stime = ev[2] duration = ev[3] xpos, ewidth = self.calcEntryPosAndWidthHelper(stime, duration, start, end, width) rec = self.timer.isInTimer(ev[0], stime, duration, service) # event box background foreColorSelected = foreColor = self.foreColor if stime <= now and now < stime + duration: backColor = self.backColorNow if isPlayableForCur(ServiceReference(service).ref): foreColor = self.foreColorNow foreColorSelected = self.foreColorSelected else: backColor = self.backColor if selected and self.select_rect.x == xpos + left and self.selEvPix: bgpng = self.selEvPix backColorSel = None elif rec is not None and rec[1][-1] in (2, 12): bgpng = self.recEvPix foreColor = self.foreColorRec backColor = self.backColorRec elif stime <= now and now < stime + duration: bgpng = self.nowEvPix elif currentservice: bgpng = self.curSerPix or self.othEvPix backColor = self.backColorServiceSelected else: bgpng = self.othEvPix if bgpng is not None: res.append(MultiContentEntryPixmapAlphaTest( pos = (left + xpos + self.eventBorderWidth, top + self.eventBorderWidth), size = (ewidth - 2 * self.eventBorderWidth, height - 2 * self.eventBorderWidth), png = bgpng, flags = BT_SCALE)) else: res.append(MultiContentEntryText( pos = (left + xpos, top), size = (ewidth, height), font = 1, flags = int(config.misc.graph_mepg.event_alignment.value), text = "", color = None, color_sel = None, backcolor = backColor, backcolor_sel = backColorSel)) # event text evX = left + xpos + self.eventBorderWidth + self.eventNamePadding evY = top + self.eventBorderWidth evW = ewidth - 2 * (self.eventBorderWidth + self.eventNamePadding) evH = height - 2 * self.eventBorderWidth if evW > 0: res.append(MultiContentEntryText( pos = (evX, evY), size = (evW, evH), font = 1, flags = int(config.misc.graph_mepg.event_alignment.value), text = ev[1], color = foreColor, color_sel = foreColorSelected)) # recording icons if rec is not None: for i in list(range(len(rec[1]))): if ewidth < (i + 1) * 22: break res.append(MultiContentEntryPixmapAlphaTest( pos = (left + xpos + ewidth - (i + 1) * 22, top + height - 22), size = (21, 21), png = self.clocks[rec[1][len(rec[1]) - 1 - i]])) else: if selected and self.selEvPix: res.append(MultiContentEntryPixmapAlphaTest( pos = (r2.x + self.eventBorderWidth, r2.y + self.eventBorderWidth), size = (r2.w - 2 * self.eventBorderWidth, r2.h - 2 * self.eventBorderWidth), png = self.selEvPix, flags = BT_SCALE)) return res
def buildEntry(self, service, service_name, events, picon): r1 = self.service_rect r2 = self.event_rect selected = self.cur_service[0] == service # Picon and Service name if CompareWithAlternatives(service, self.currentlyPlaying and self.currentlyPlaying.toString()): serviceForeColor = self.foreColorServiceSelected serviceBackColor = self.backColorServiceSelected bgpng = self.curSerPix or self.nowEvPix currentservice = True else: serviceForeColor = self.foreColorService serviceBackColor = self.backColorService bgpng = self.othEvPix currentservice = False res = [ None ] if bgpng is not None: # bacground for service rect res.append(MultiContentEntryPixmapAlphaTest( pos = (r1.x + self.serviceBorderWidth, r1.y + self.serviceBorderWidth), size = (r1.w - 2 * self.serviceBorderWidth, r1.h - 2 * self.serviceBorderWidth), png = bgpng, flags = BT_SCALE)) else: res.append(MultiContentEntryText( pos = (r1.x, r1.y), size = (r1.w, r1.h), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_CENTER, text = "", color = serviceForeColor, color_sel = serviceForeColor, backcolor = serviceBackColor, backcolor_sel = serviceBackColor)) displayPicon = None if self.showPicon: if picon is None: # go find picon and cache its location picon = getPiconName(service) curIdx = self.l.getCurrentSelectionIndex() self.list[curIdx] = (service, service_name, events, picon) piconWidth = self.picon_size.width() piconHeight = self.picon_size.height() if picon != "": displayPicon = loadPNG(picon) if displayPicon is not None: res.append(MultiContentEntryPixmapAlphaTest( pos = (r1.x + self.serviceBorderWidth, r1.y + self.serviceBorderWidth), size = (piconWidth, piconHeight), png = displayPicon, backcolor = None, backcolor_sel = None, flags = BT_SCALE | BT_KEEP_ASPECT_RATIO)) elif not self.showServiceTitle: # no picon so show servicename anyway in picon space namefont = 1 namefontflag = int(config.misc.graph_mepg.servicename_alignment.value) namewidth = piconWidth piconWidth = 0 else: piconWidth = 0 if self.showServiceTitle: # we have more space so reset parms namefont = 0 namefontflag = int(config.misc.graph_mepg.servicename_alignment.value) namewidth = r1.w - piconWidth if self.showServiceTitle or displayPicon is None: res.append(MultiContentEntryText( pos = (r1.x + piconWidth + self.serviceBorderWidth + self.serviceNamePadding, r1.y + self.serviceBorderWidth), size = (namewidth - 2 * (self.serviceBorderWidth + self.serviceNamePadding), r1.h - 2 * self.serviceBorderWidth), font = namefont, flags = namefontflag, text = service_name, color = serviceForeColor, color_sel = serviceForeColor, backcolor = None, backcolor_sel = None)) # Events for service backColorSel = self.backColorSelected if events: start = self.time_base + self.offs * self.time_epoch * 60 end = start + self.time_epoch * 60 left = r2.x top = r2.y width = r2.w height = r2.h now = time() for ev in events: #(event_id, event_title, begin_time, duration) stime = ev[2] duration = ev[3] xpos, ewidth = self.calcEntryPosAndWidthHelper(stime, duration, start, end, width) rec = self.timer.isInTimer(ev[0], stime, duration, service) # event box background foreColorSelected = foreColor = self.foreColor if stime <= now and now < stime + duration: backColor = self.backColorNow if isPlayableForCur(ServiceReference(service).ref): foreColor = self.foreColorNow foreColorSelected = self.foreColorSelected else: backColor = self.backColor if selected and self.select_rect.x == xpos + left and self.selEvPix: bgpng = self.selEvPix backColorSel = None elif rec is not None and rec[1][-1] in (2, 12): bgpng = self.recEvPix foreColor = self.foreColorRec backColor = self.backColorRec elif stime <= now and now < stime + duration: bgpng = self.nowEvPix elif currentservice: bgpng = self.curSerPix or self.othEvPix backColor = self.backColorServiceSelected else: bgpng = self.othEvPix if bgpng is not None: res.append(MultiContentEntryPixmapAlphaTest( pos = (left + xpos + self.eventBorderWidth, top + self.eventBorderWidth), size = (ewidth - 2 * self.eventBorderWidth, height - 2 * self.eventBorderWidth), png = bgpng, flags = BT_SCALE)) else: res.append(MultiContentEntryText( pos = (left + xpos, top), size = (ewidth, height), font = 1, flags = int(config.misc.graph_mepg.event_alignment.value), text = "", color = None, color_sel = None, backcolor = backColor, backcolor_sel = backColorSel)) # event text evX = left + xpos + self.eventBorderWidth + self.eventNamePadding evY = top + self.eventBorderWidth evW = ewidth - 2 * (self.eventBorderWidth + self.eventNamePadding) evH = height - 2 * self.eventBorderWidth if evW > 0: res.append(MultiContentEntryText( pos = (evX, evY), size = (evW, evH), font = 1, flags = int(config.misc.graph_mepg.event_alignment.value), text = ev[1], color = foreColor, color_sel = foreColorSelected)) # recording icons if rec is not None: for i in range(len(rec[1])): if ewidth < (i + 1) * 22: break res.append(MultiContentEntryPixmapAlphaTest( pos = (left + xpos + ewidth - (i + 1) * 22, top + height - 22), size = (21, 21), png = self.clocks[rec[1][len(rec[1]) - 1 - i]])) else: if selected and self.selEvPix: res.append(MultiContentEntryPixmapAlphaTest( pos = (r2.x + self.eventBorderWidth, r2.y + self.eventBorderWidth), size = (r2.w - 2 * self.eventBorderWidth, r2.h - 2 * self.eventBorderWidth), png = self.selEvPix, flags = BT_SCALE)) return res
def ResolveCiAlternative(ref, ignore_ref=None, record_mode=False): if ref and isinstance(ref, eServiceReference): if ref.flags & eServiceReference.isGroup: serviceList = eServiceCenter.getInstance() and eServiceCenter.getInstance().list(ref) prio_list = [] prio_val = int(config.usage.alternatives_priority.value) if serviceList: for service in serviceList.getContent("R"): if not ignore_ref or service != ignore_ref: refstr = service.toString() def resolveRecordLiveMode(): if record_mode: is_assignment = cihelper.ServiceIsAssigned(refstr) if not is_assignment or is_assignment[0] != record_mode[0]: return True elif cihelper.canMultiDescramble(is_assignment[0]): eService = eServiceReference(record_mode[1]) for x in (4, 2, 3): if service.getUnsignedData(x) != eService.getUnsignedData(x): return False else: return False return True if resolveRecordLiveMode() and (service.getPath() or isPlayableForCur(service)): if prio_val == 127: return service else: type = ("%3a//" in refstr and 4) or ('EEEE0000' in refstr and 2) or ('FFFF0000' in refstr and 3) or 1 prio_list.append((service, type)) num = len(prio_list) if num == 1: return prio_list[0][0] elif num > 1: prio_map = [(3, 2, 1),# -S -C -T (3, 1, 2),# -S -T -C (2, 3, 1),# -C -S -T (1, 3, 2),# -C -T -S (1, 2, 3),# -T -C -S (2, 1, 3) # -T -S -C ] cur = tmp = 0 stream_service = service = None for x in prio_list: if x[1] == 2: tmp = prio_map[prio_val][2] elif x[1] == 3: tmp = prio_map[prio_val][1] elif x[1] == 1: tmp = prio_map[prio_val][0] if tmp > cur: cur = tmp service = x[0] if x[1] == 4 and not stream_service: stream_service = x[0] if cur > 0: return service if stream_service: return stream_service elif ref.getPath() or isPlayableForCur(ref): return ref return None
def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust=True): session = None startPlayingServiceOrGroup = None count = isinstance(adjust, list) and len(adjust) or 0 if count > 1 and adjust[0] is 0: session = adjust[1] if count == 3: startPlayingServiceOrGroup = adjust[2] adjust = adjust[0] oldref = self.currentlyPlayingServiceOrGroup if ref and oldref and ref == oldref and not forceRestart: print "[Navigation] ignore request to play already running service(1)" return 1 print "[Navigation] playing: ", ref and ref.toString() if ref is None: self.stopService() return 0 from Components.ServiceEventTracker import InfoBarCount InfoBarInstance = InfoBarCount == 1 and InfoBar.instance if not checkParentalControl or parentalControl.isServicePlayable( ref, boundFunction(self.playService, checkParentalControl=False, forceRestart=forceRestart, adjust=(count > 1 and [0, session] or adjust)), session=session): if ref.flags & eServiceReference.isGroup: oldref = self.currentlyPlayingServiceReference or eServiceReference( ) playref = getBestPlayableServiceReference(ref, oldref) if playref and config.misc.use_ci_assignment.value and not isPlayableForCur( playref): alternative_ci_ref = ResolveCiAlternative(ref, playref) if alternative_ci_ref: playref = alternative_ci_ref print "[Navigation] alternative ref: ", playref and playref.toString( ) if playref and oldref and playref == oldref and not forceRestart: print "[Navigation] ignore request to play already running service(2)" return 1 if not playref: alternativeref = getBestPlayableServiceReference( ref, eServiceReference(), True) self.stopService() if alternativeref and self.pnav: self.currentlyPlayingServiceReference = alternativeref self.currentlyPlayingServiceOrGroup = ref if self.pnav.playService(alternativeref): print "[Navigation] Failed to start: ", alternativeref.toString( ) self.currentlyPlayingServiceReference = None self.currentlyPlayingServiceOrGroup = None else: print "[Navigation] alternative ref as simulate: ", alternativeref.toString( ) return 0 elif checkParentalControl and not parentalControl.isServicePlayable( playref, boundFunction(self.playService, checkParentalControl=False, forceRestart=forceRestart, adjust=(count > 1 and [0, session, ref] or adjust)), session=session): if self.currentlyPlayingServiceOrGroup and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent( self.currentlyPlayingServiceOrGroup, adjust): self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent( ) return 1 else: playref = ref if self.pnav: if SystemInfo["FCCactive"] and not self.pnav.playService( playref): self.currentlyPlayingServiceReference = playref self.currentlyPlayingServiceOrGroup = ref return 0 self.pnav.stopService() self.currentlyPlayingServiceReference = playref self.currentlyPlayingServiceOrGroup = ref if startPlayingServiceOrGroup and startPlayingServiceOrGroup.flags & eServiceReference.isGroup and not ref.flags & eServiceReference.isGroup: self.currentlyPlayingServiceOrGroup = startPlayingServiceOrGroup if InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent( ref, adjust): self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent( ) setPriorityFrontend = False if SystemInfo["DVB-T_priority_tuner_available"] or SystemInfo[ "DVB-C_priority_tuner_available"] or SystemInfo[ "DVB-S_priority_tuner_available"] or SystemInfo[ "ATSC_priority_tuner_available"]: str_service = playref.toString() if '%3a//' not in str_service and not str_service.rsplit( ":", 1)[1].startswith("/"): type_service = playref.getUnsignedData(4) >> 16 if type_service == 0xEEEE: if SystemInfo[ "DVB-T_priority_tuner_available"] and config.usage.frontend_priority_dvbt.value != "-2": if config.usage.frontend_priority_dvbt.value != config.usage.frontend_priority.value: setPreferredTuner( int(config.usage. frontend_priority_dvbt.value)) setPriorityFrontend = True if SystemInfo[ "ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2": if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value: setPreferredTuner( int(config.usage. frontend_priority_atsc.value)) setPriorityFrontend = True elif type_service == 0xFFFF: if SystemInfo[ "DVB-C_priority_tuner_available"] and config.usage.frontend_priority_dvbc.value != "-2": if config.usage.frontend_priority_dvbc.value != config.usage.frontend_priority.value: setPreferredTuner( int(config.usage. frontend_priority_dvbc.value)) setPriorityFrontend = True if SystemInfo[ "ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2": if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value: setPreferredTuner( int(config.usage. frontend_priority_atsc.value)) setPriorityFrontend = True else: if SystemInfo[ "DVB-S_priority_tuner_available"] and config.usage.frontend_priority_dvbs.value != "-2": if config.usage.frontend_priority_dvbs.value != config.usage.frontend_priority.value: setPreferredTuner( int(config.usage. frontend_priority_dvbs.value)) setPriorityFrontend = True if self.pnav.playService(playref): print "[Navigation] Failed to start: ", playref.toString() self.currentlyPlayingServiceReference = None self.currentlyPlayingServiceOrGroup = None if setPriorityFrontend: setPreferredTuner(int( config.usage.frontend_priority.value)) return 0 elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent( oldref, adjust): self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent( ) return 1