Example #1
0
def resolveAlternate(ref):
    nref = None
    if ref.flags & eServiceReference.isGroup:
        nref = getBestPlayableServiceReference(ref, getPlayingref(ref))
        if not nref:
            nref = getBestPlayableServiceReference(ref, eServiceReference(), True)
    return nref
Example #2
0
    def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust=True):
        oldref = self.currentlyPlayingServiceOrGroup
        if ref and oldref and ref == oldref and not forceRestart:
            print "ignore request to play already running service(1)"
            return 1
        print "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=adjust)
        ):
            if ref.flags & eServiceReference.isGroup:
                oldref = self.currentlyPlayingServiceReference or eServiceReference()
                playref = getBestPlayableServiceReference(ref, oldref)
                print "playref", playref
                if playref and oldref and playref == oldref and not forceRestart:
                    print "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 and self.pnav.playService(alternativeref):
                        print "Failed to start", alternativeref
                    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()

                if self.pnav.playService(playref):
                    print "Failed to start", playref
                    self.currentlyPlayingServiceReference = None
                    self.currentlyPlayingServiceOrGroup = None
                return 0
        elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(oldref, adjust):
            self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent()
        return 1
Example #3
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 #4
0
	def tryPrepare(self):
		if self.justplay:
			return True
		else:
			if not self.calculateFilename():
				self.do_backoff()
				self.start_prepare = time() + self.backoff
				return False
			rec_ref = self.service_ref and self.service_ref.ref
			if rec_ref and rec_ref.flags & eServiceReference.isGroup:
				rec_ref = getBestPlayableServiceReference(rec_ref, eServiceReference())
				if not rec_ref:
					self.log(1, "'get best playable service for group... record' failed")
					return False

			self.setRecordingPreferredTuner()
			try:
				#not all images support recording type indicators
				self.record_service = rec_ref and NavigationInstance.instance.recordService(rec_ref,False,pNavigation.isRealRecording)
			except:
				self.record_service = rec_ref and NavigationInstance.instance.recordService(rec_ref)

			if not self.record_service:
				self.log(1, "'record service' failed")
				self.setRecordingPreferredTuner(setdefault=True)
				return False

			if self.repeated:
				epgcache = eEPGCache.getInstance()
				queryTime=self.begin+(self.end-self.begin)/2
				evt = epgcache.lookupEventTime(rec_ref, queryTime)
				if evt:
					self.description = evt.getShortDescription()
					if self.description == "":
						self.description = evt.getExtendedDescription()
					event_id = evt.getEventId()
				else:
					event_id = -1
			else:
				event_id = self.eit
				if event_id is None:
					event_id = -1

			prep_res=self.record_service.prepare(self.Filename + ".ts", self.begin, self.end, event_id, self.name.replace("\n", ""), self.description.replace("\n", ""), ' '.join(self.tags), self.descramble, self.record_ecm)
			if prep_res:
				if prep_res == -255:
					self.log(4, "failed to write meta information")
				else:
					self.log(2, "'prepare' failed: error %d" % prep_res)

				# we must calc new start time before stopRecordService call because in Screens/Standby.py TryQuitMainloop tries to get
				# the next start time in evEnd event handler...
				self.do_backoff()
				self.start_prepare = time() + self.backoff

				NavigationInstance.instance.stopRecordService(self.record_service)
				self.record_service = None
				self.setRecordingPreferredTuner(setdefault=True)
				return False
			return True
Example #5
0
	def getServiceProvider(self, ref):
		if isinstance(ref, eServiceReference):
			str_ref = ref.toString()
			if str_ref.startswith('1:134:'):
				ref = getBestPlayableServiceReference(ref, eServiceReference())
				if not ref:
					return _("N/A")
			typestr = ref.getData(0) in (2,10) and service_types_radio or service_types_tv
			pos = typestr.rfind(':')
			rootstr = '%s (channelID == %08x%04x%04x) && %s FROM PROVIDERS ORDER BY name'%(typestr[:pos+1],
				ref.getUnsignedData(4), # NAMESPACE
				ref.getUnsignedData(2), # TSID
				ref.getUnsignedData(3), # ONID
				typestr[pos+1:])
			provider_root = eServiceReference(rootstr)
			serviceHandler = eServiceCenter.getInstance()
			providerlist = serviceHandler.list(provider_root)
			if not providerlist is None:
				while True:
					provider = providerlist.getNext()
					if not provider.valid(): break
					if provider.flags & eServiceReference.isDirectory:
						servicelist = serviceHandler.list(provider)
						if not servicelist is None:
							while True:
								service = servicelist.getNext()
								if not service.valid(): break
								if service == ref:
									info = serviceHandler.info(provider)
									name = info and info.getName(provider) or _("Unknown")
									return name
		return _("N/A")
Example #6
0
	def tryPrepare(self):
		if self.justplay:
			return True
		else:
			if not self.calculateFilename():
				self.do_backoff()
				self.start_prepare = time() + self.backoff
				return False
			rec_ref = self.service_ref and self.service_ref.ref
			if rec_ref and rec_ref.flags & eServiceReference.isGroup:
				rec_ref = getBestPlayableServiceReference(rec_ref, eServiceReference())
				if not rec_ref:
					self.log(1, "'get best playable service for group... record' failed")
					return False

			self.setRecordingPreferredTuner()
			try:
				#not all images support recording type indicators
				self.record_service = rec_ref and NavigationInstance.instance.recordService(rec_ref,False,pNavigation.isRealRecording)
			except:
				self.record_service = rec_ref and NavigationInstance.instance.recordService(rec_ref)

			if not self.record_service:
				self.log(1, "'record service' failed")
				self.setRecordingPreferredTuner(setdefault=True)
				return False

			if self.repeated:
				epgcache = eEPGCache.getInstance()
				queryTime=self.begin+(self.end-self.begin)/2
				evt = epgcache.lookupEventTime(rec_ref, queryTime)
				if evt:
					self.description = evt.getShortDescription()
					if self.description == "":
						self.description = evt.getExtendedDescription()
					event_id = evt.getEventId()
				else:
					event_id = -1
			else:
				event_id = self.eit
				if event_id is None:
					event_id = -1

			prep_res=self.record_service.prepare(self.Filename + ".ts", self.begin, self.end, event_id, self.name.replace("\n", ""), self.description.replace("\n", ""), ' '.join(self.tags), self.descramble, self.record_ecm)
			if prep_res:
				if prep_res == -255:
					self.log(4, "failed to write meta information")
				else:
					self.log(2, "'prepare' failed: error %d" % prep_res)

				# we must calc new start time before stopRecordService call because in Screens/Standby.py TryQuitMainloop tries to get
				# the next start time in evEnd event handler...
				self.do_backoff()
				self.start_prepare = time() + self.backoff

				NavigationInstance.instance.stopRecordService(self.record_service)
				self.record_service = None
				self.setRecordingPreferredTuner(setdefault=True)
				return False
			return True
Example #7
0
 def ciRecordEvent(self, service, event):
     if event in (iRecordableService.evEnd, iRecordableService.evStart,
                  None):
         self.CI_RECORDS_LIST = []
         if NavigationInstance.instance.getRecordings():
             for timer in NavigationInstance.instance.RecordTimer.timer_list:
                 if not timer.justplay and timer.state in (
                         1, 2) and timer.record_service and not (
                             timer.record_ecm and not timer.descramble):
                     if timer.service_ref.ref.flags & eServiceReference.isGroup:
                         timerservice = hasattr(timer,
                                                "rec_ref") and timer.rec_ref
                         if not timerservice:
                             timerservice = getBestPlayableServiceReference(
                                 timer.service_ref.ref, eServiceReference())
                     else:
                         timerservice = timer.service_ref.ref
                     if timerservice:
                         timerstr = timerservice.toString()
                         is_assignment = self.ServiceIsAssigned(timerstr)
                         if is_assignment:
                             if is_assignment[
                                     0] not in self.CI_RECORDS_LIST:
                                 self.CI_RECORDS_LIST.insert(
                                     0, is_assignment[0])
                             if is_assignment not in self.CI_RECORDS_LIST:
                                 self.CI_RECORDS_LIST.append(is_assignment)
Example #8
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 #9
0
 def playService(self, ref, checkParentalControl=True):
     oldref = self.currentlyPlayingServiceReference
     if ref and oldref and ref == oldref:
         print "ignore request to play already running service"
         return 0
     print "playing", ref and ref.toString()
     if ref is None:
         self.stopService()
         return 0
     if not checkParentalControl or parentalControl.isServicePlayable(
             ref, boundFunction(self.playService,
                                checkParentalControl=False)):
         if ref.flags & eServiceReference.isGroup:
             if not oldref:
                 oldref = eServiceReference()
             playref = getBestPlayableServiceReference(ref, oldref)
             if not playref or (
                     checkParentalControl
                     and not parentalControl.isServicePlayable(
                         playref,
                         boundFunction(self.playService,
                                       checkParentalControl=False))):
                 self.stopService()
                 return 0
         else:
             playref = ref
         if self.pnav and not self.pnav.playService(playref):
             self.currentlyPlayingServiceReference = playref
             return 0
     else:
         self.stopService()
     return 1
Example #10
0
 def setPiPService(self):
     if self.shown:
         service = self.source.getCurrentService()
         if self.currentRunningService is None or self.pipservice is None:
             self.currentRunningService = service
         # check, if tuner with the service is available
         service_center = eServiceCenter.getInstance()
         info = service_center.info(service)
         if info and info.isPlayable(service, self.currentRunningService):
             if service and (service.flags & eServiceReference.isGroup):
                 ref = getBestPlayableServiceReference(
                     service, eServiceReference())
             else:
                 ref = service
             if ref and not (ref.flags & (eServiceReference.isMarker
                                          | eServiceReference.isDirectory)):
                 if self.pipServiceRelation is not None:
                     n_service = self.pipServiceRelation.get(
                         ref.toString(), None)
                     if n_service is not None:
                         self.pipservice = eServiceCenter.getInstance(
                         ).play(eServiceReference(n_service))
                     else:
                         self.pipservice = eServiceCenter.getInstance(
                         ).play(ref)
                 else:
                     self.pipservice = eServiceCenter.getInstance().play(
                         ref)
                 if self.pipservice and not self.pipservice.setTarget(1):
                     self.pipservice.start()
                     return True
     self.pipservice = None
     return False
Example #11
0
 def playService(self, service):
     if parentalControl.getProtectionLevel(service.toCompareString(
     )) == -1 or (
             parentalControl.configInitialized
             and parentalControl.sessionPinCached
             and parentalControl.sessionPinCachedValue
     ):  # check parentalControl, only play a protected service when Pin-Cache is activated and still valid
         current_service = service
         n_service = self.pipServiceRelation.get(service.toString(),
                                                 None)  # PiPServiceRelation
         if n_service is not None:
             service = eServiceReference(n_service)
         if service and (service.flags & eServiceReference.isGroup):
             ref = getBestPlayableServiceReference(service,
                                                   eServiceReference())
         else:
             ref = service
         if ref and ref.toString() != self.currentPiP:
             self.pipservice = eServiceCenter.getInstance().play(ref)
             if self.pipservice and not self.pipservice.setTarget(1):
                 self.pipservice.start()
                 self.currentPiP = current_service.toString()
             else:
                 self.pipservice = None
                 self.currentPiP = ""
     else:
         self.pipservice = None
         self.currentPiP = ""
Example #12
0
	def addServices(self, fromList, toList, channelIds):
		for scanservice in fromList:
			service = eServiceReference(scanservice.sref)
			if (service.flags & eServiceReference.isGroup):
				service = getBestPlayableServiceReference(eServiceReference(scanservice.sref), eServiceReference())

			# service can be a "NoneType" without attribute "valid" -> Crash
			try:
				if not service.valid():
					continue
			except:
				continue

			if (service.flags & (eServiceReference.isMarker|eServiceReference.isDirectory)):
				continue

			channelID = '%08x%04x%04x' % (
				service.getUnsignedData(4), # NAMESPACE
				service.getUnsignedData(2), # TSID
				service.getUnsignedData(3), # ONID
			)

			if channelID not in channelIds:
				toList.append(scanservice)
				channelIds.append(channelID)
Example #13
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
Example #14
0
	def getServiceProvider(self, ref):
		if isinstance(ref, eServiceReference):
			str_ref = ref.toString()
			if str_ref.startswith('1:134:'):
				ref = getBestPlayableServiceReference(ref, eServiceReference())
				if not ref:
					return _("N/A")
			typestr = ref.getData(0) in (2,10) and service_types_radio or service_types_tv
			pos = typestr.rfind(':')
			rootstr = '%s (channelID == %08x%04x%04x) && %s FROM PROVIDERS ORDER BY name'%(typestr[:pos+1],
				ref.getUnsignedData(4), # NAMESPACE
				ref.getUnsignedData(2), # TSID
				ref.getUnsignedData(3), # ONID
				typestr[pos+1:])
			provider_root = eServiceReference(rootstr)
			serviceHandler = eServiceCenter.getInstance()
			providerlist = serviceHandler.list(provider_root)
			if not providerlist is None:
				while True:
					provider = providerlist.getNext()
					if not provider.valid(): break
					if provider.flags & eServiceReference.isDirectory:
						servicelist = serviceHandler.list(provider)
						if not servicelist is None:
							while True:
								service = servicelist.getNext()
								if not service.valid(): break
								if service == ref:
									info = serviceHandler.info(provider)
									name = info and info.getName(provider) or _("Unknown")
									return name
		return _("N/A")
	def setPiPService(self):
		if self.shown:
			service = self.source.getCurrentService()
			if self.currentRunningService is None or self.pipservice is None:
				self.currentRunningService = service
			# check, if tuner with the service is available
			service_center = eServiceCenter.getInstance()
			info = service_center.info(service)
			if info and info.isPlayable(service, self.currentRunningService):
				if service and (service.flags & eServiceReference.isGroup):
					ref = getBestPlayableServiceReference(service, eServiceReference())
				else:
					ref = service
				if ref and not (ref.flags & (eServiceReference.isMarker|eServiceReference.isDirectory)):
					if self.pipServiceRelation is not None:
						n_service = self.pipServiceRelation.get(ref.toString(),None)
						if n_service is not None:
							self.pipservice = eServiceCenter.getInstance().play(eServiceReference(n_service))
						else:
							self.pipservice = eServiceCenter.getInstance().play(ref)
					else:
						self.pipservice = eServiceCenter.getInstance().play(ref)
					if self.pipservice and not self.pipservice.setTarget(1):
						self.pipservice.start()
						return True
		self.pipservice = None
		return False
Example #16
0
	def playService(self, ref, checkParentalControl = True, forceRestart = False):
		if not self.immediatePlay:
			print("delaying playService request until the ChannelSelection is finally initialized")
			self.scheduledServiceReference = (ref, checkParentalControl, forceRestart)
			return
		oldref = self.currentlyPlayingServiceReference
		if ref and oldref and ref == oldref and not forceRestart:
			print("ignore request to play already running service(1)")
			return 0
		print("playing", ref and ref.toString())
		if ref is None:
			self.stopService()
			return 0
		if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
			if ref.flags & eServiceReference.isGroup:
				if not oldref:
					oldref = eServiceReference()
				playref = getBestPlayableServiceReference(ref, oldref)
				print("playref", playref)
				if playref and oldref and playref == oldref and not forceRestart:
					print("ignore request to play already running service(2)")
					return 0
				if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
					self.stopService()
					return 0
			else:
				playref = ref
			if self.pnav and not self.pnav.playService(playref):
				self.currentlyPlayingServiceReference = self.pnav.getCurrentServiceReference();
				return 0
		else:
			self.stopService()
		return 1
Example #17
0
	def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust=True):
		oldref = self.currentlyPlayingServiceOrGroup
		if ref and oldref and ref == oldref and not forceRestart:
			print "ignore request to play already running service(1)"
			return 0
		print "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
				f = open("/proc/stb/lcd/symbol_signal", "w")
				f.write(str(signal))
				f.close()
			except:
				f = open("/proc/stb/lcd/symbol_signal", "w")
				f.write("0")
				f.close()
		elif path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.value == '0':
			f = open("/proc/stb/lcd/symbol_signal", "w")
			f.write("0")
			f.close()

		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)
				print "playref", playref
				if playref and oldref and playref == oldref and not forceRestart:
					print "ignore request to play already running service(2)"
					return 0
				if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
					self.stopService()
					return 0
			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()

				if ref.toString().find('//') == -1 and SystemInfo["isGBIPBOX"]:
					playref = ZAP.gref(ref, self.pnav)

				if self.pnav.playService(playref):
					print "Failed to start", playref
					self.currentlyPlayingServiceReference = None
					self.currentlyPlayingServiceOrGroup = None
				return 0
		elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(oldref, adjust):
			self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent()
		return 1
Example #18
0
	def playService(self, ref, checkParentalControl = True, forceRestart = False):
		oldref = self.currentlyPlayingServiceReference
		if ref and oldref and ref == oldref and not forceRestart:
			print "ignore request to play already running service(1)"
			return 0
		#print "playing", ref and ref.toString()
		print "playing service.."
		if ref is None:
			self.stopService()
			return 0
		if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
			if ref.flags & eServiceReference.isGroup:
				if not oldref:
					oldref = eServiceReference()
				playref = getBestPlayableServiceReference(ref, oldref)
				print "playref", playref
				if playref and oldref and playref == oldref and not forceRestart:
					print "ignore request to play already running service(2)"
					return 0
				if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
					self.stopService()
					return 0
			else:
				playref = ref
			if self.pnav and not self.pnav.playService(playref):
				self.currentlyPlayingServiceReference = playref
				return 0
		else:
			self.stopService()
		return 1
Example #19
0
    def addServices(self, fromList, toList, channelIds):
        for scanservice in fromList:
            service = eServiceReference(scanservice.sref)
            if (service.flags & eServiceReference.isGroup):
                service = getBestPlayableServiceReference(
                    eServiceReference(scanservice.sref), eServiceReference())

            # service can be a "NoneType" without attribute "valid" -> Crash
            try:
                if not service.valid():
                    continue
            except:
                continue

            if (service.flags &
                (eServiceReference.isMarker | eServiceReference.isDirectory)):
                continue

            channelID = '%08x%04x%04x' % (
                service.getUnsignedData(4),  # NAMESPACE
                service.getUnsignedData(2),  # TSID
                service.getUnsignedData(3),  # ONID
            )

            if channelID not in channelIds:
                toList.append(scanservice)
                channelIds.append(channelID)
Example #20
0
	def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust=True):
		oldref = self.currentlyPlayingServiceOrGroup
		if ref and oldref and ref == oldref and not forceRestart:
			print "ignore request to play already running service(1)"
			return 0
		print "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
				f = open("/proc/stb/lcd/symbol_signal", "w")
				f.write(str(signal))
				f.close()
			except:
				f = open("/proc/stb/lcd/symbol_signal", "w")
				f.write("0")
				f.close()
		elif path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.value == '0':
			f = open("/proc/stb/lcd/symbol_signal", "w")
			f.write("0")
			f.close()

		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)
				print "playref", playref
				if playref and oldref and playref == oldref and not forceRestart:
					print "ignore request to play already running service(2)"
					return 0
				if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
					self.stopService()
					return 0
			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()

				if ref.toString().find('/') == -1 and SystemInfo["isGBIPBOX"]:
					playref = ZAP.gref(ref, self.pnav)

				if self.pnav.playService(playref):
					print "Failed to start", playref
					self.currentlyPlayingServiceReference = None
					self.currentlyPlayingServiceOrGroup = None
				return 0
		elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(oldref, adjust):
			self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent()
		return 1
Example #21
0
def HistoryZapBrowserListEntry(ref, serviceName, eventName, siact = False):
    res = [serviceName]
    ancho = 480
    if config.plugins.spzHistoryZapConf.viewMode.value == 'picons':
        try:
            if ref.flags & eServiceReference.isGroup:
                ref = getBestPlayableServiceReference(ref, eServiceReference(), True)
        except:
            pass

        sname = ref.toString()
        pngname = ''
        pngname = findPicon(sname)
        if pngname == '':
            tmp = resolveFilename(SCOPE_CURRENT_SKIN, 'picon_default.png')
            if fileExists(tmp):
                pngname = tmp
            else:
                pngname = resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/picon_default.png')
        try:
            png = LoadPixmap(pngname)
            res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND,
             0,
             5,
             100,
             65,
             png))
        except:
            pass

        xch = 105
        ych = 3
        xev = 105
        ancho = ancho - xev
        yev = 26
        lasflags = RT_HALIGN_LEFT | RT_WRAP
    elif config.plugins.spzHistoryZapConf.viewMode.value == 'menu':
        if siact:
            png = LoadPixmap('/usr/lib/enigma2/python/Plugins/Extensions/spzZapHistory/res/vtv.png')
        else:
            png = LoadPixmap('/usr/lib/enigma2/python/Plugins/Extensions/spzZapHistory/res/tv.png')
        xch = 30
        ych = -1
        xev = 40
        yev = 20
        lasflags = RT_HALIGN_LEFT
        res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND,
         5,
         3,
         20,
         20,
         png))
    else:
        ancho = 330
        xch = 0
        ych = 0
    if config.plugins.spzHistoryZapConf.viewMode.value != 'simple':
        res.append(MultiContentEntryText(pos=(xev, yev), size=(ancho, 40), font=1, flags=lasflags, text=eventName, color=8947848))
    res.append(MultiContentEntryText(pos=(xch, ych), size=(ancho, 25), font=0, text=serviceName))
    return res
Example #22
0
def getStream(session, request, m3ufile):

	if "ref" in request.args:
		sRef=unquote(unquote(request.args["ref"][0]).decode('utf-8', 'ignore')).encode('utf-8')
	else:
		sRef = ""
	
	currentServiceRef = None
	if m3ufile == "streamcurrent.m3u":
		currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		sRef = currentServiceRef.toString() 
	
	if sRef.startswith("1:134:"):
		if currentServiceRef is None:
			currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		if currentServiceRef is None:
			currentServiceRef = eServiceReference()
		ref = getBestPlayableServiceReference(eServiceReference(sRef), currentServiceRef)
		if ref is None:
			sRef = ""
		else:
			sRef = ref.toString()

	name = "stream"
	if "name" in request.args:
		name = request.args["name"][0]
	# #EXTINF:-1,%s\n  remove not compatiple with old api
	if sRef != '':
		progopt="#EXTVLCOPT:program=%d\n" % (int(sRef.split(':')[3],16))
	else:
		progopt=""
	response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:%s/%s\n" % (progopt,request.getRequestHostname(),config.OpenWebif.streamport.value, sRef)
	request.setHeader('Content-Type', 'application/text')
	return response
Example #23
0
	def playService(self, ref, checkParentalControl = True, forceRestart = False):
		if not self.immediatePlay:
			print "delaying playService request until the ChannelSelection is finally initialized"
			self.scheduledServiceReference = (ref, checkParentalControl, forceRestart)
			return
		oldref = self.currentlyPlayingServiceReference
		if ref and oldref and ref == oldref and not forceRestart:
			print "ignore request to play already running service(1)"
			return 0
		print "playing", ref and ref.toString()
		if ref is None:
			self.stopService()
			return 0
		if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
			if ref.flags & eServiceReference.isGroup:
				if not oldref:
					oldref = eServiceReference()
				playref = getBestPlayableServiceReference(ref, oldref)
				print "playref", playref
				if playref and oldref and playref == oldref and not forceRestart:
					print "ignore request to play already running service(2)"
					return 0
				if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
					self.stopService()
					return 0
			else:
				playref = ref
			if self.pnav and not self.pnav.playService(playref):
				self.currentlyPlayingServiceReference = self.pnav.getCurrentServiceReference();
				return 0
		else:
			self.stopService()
		return 1
Example #24
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
Example #25
0
	def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust=True):
		oldref = self.currentlyPlayingServiceOrGroup
		if ref and oldref and ref == oldref and not forceRestart:
			print "ignore request to play already running service(1)"
			return 1
		print "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=adjust)):
			if ref.flags & eServiceReference.isGroup:
				oldref = self.currentlyPlayingServiceReference or eServiceReference()
				playref = getBestPlayableServiceReference(ref, oldref)
				print "playref", playref
				if playref and oldref and playref == oldref and not forceRestart:
					print "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 and self.pnav.playService(alternativeref):
						print "Failed to start", alternativeref
					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()

				if self.pnav.playService(playref):
					print "Failed to start", playref
					self.currentlyPlayingServiceReference = None
					self.currentlyPlayingServiceOrGroup = None
				return 0
		elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(oldref, adjust):
			self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent()
		return 1
Example #26
0
def getPlayableService(sRef, sRefPlaying):
	return {
		"result": True,
		"service": {
			"servicereference": sRef,
			"isplayable": getBestPlayableServiceReference(eServiceReference(sRef), eServiceReference(sRefPlaying)) != None
		}
	}
Example #27
0
    def playService(self, ref, checkParentalControl=True, forceRestart=False):
        oldref = self.currentlyPlayingServiceReference
        if ref and oldref and ref == oldref and not forceRestart:
            print "ignore request to play already running service(1)"
            return 0
        print "playing", ref and ref.toString()
        if path.exists("/proc/stb/lcd/symbol_signal"
                       ) and config.lcd.mode.getValue() == '1':
            try:
                if ref.toString().find('0:0:0:0:0:0:0:0:0') == -1:
                    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.getValue() == '0':
            open("/proc/stb/lcd/symbol_signal", "w").write("0")

        if ref is None:
            self.stopService()
            return 0
        if not checkParentalControl or parentalControl.isServicePlayable(
                ref, boundFunction(self.playService,
                                   checkParentalControl=False)):
            if ref.flags & eServiceReference.isGroup:
                if not oldref:
                    oldref = eServiceReference()
                playref = getBestPlayableServiceReference(ref, oldref)
                print "playref", playref
                if playref and oldref and playref == oldref and not forceRestart:
                    print "ignore request to play already running service(2)"
                    return 0
                if not playref or (
                        checkParentalControl
                        and not parentalControl.isServicePlayable(
                            playref,
                            boundFunction(self.playService,
                                          checkParentalControl=False))):
                    self.stopService()
                    return 0
            else:
                playref = ref
            if self.pnav:
                self.pnav.stopService()
                self.currentlyPlayingServiceReference = playref
                self.currentlyPlayingSelectedServiceReference = ref
                InfoBarInstance = InfoBar.instance
                if InfoBarInstance is not None:
                    InfoBarInstance.servicelist.servicelist.setCurrent(ref)
                if self.pnav.playService(playref):
                    print "Failed to start", playref
                    self.currentlyPlayingServiceReference = None
                return 0
        else:
            self.stopService()
        return 1
Example #28
0
    def tryPrepare(self):
        if self.justplay == 1:
            return True
        if self.justplay == 2:
            if Screens.Standby.inStandby:
                # Screens.Standby.inStandby.prev_running_service = self.service_ref.ref
                Screens.Standby.inStandby.Power()
            os.system("echo `date` '[TIMER] EPG Initilize....' > /usr/log/crossepg.log")
            self.t = timerEpgDownload()
            return True
        elif self.justplay == 0:
            self.calculateFilename()
            rec_ref = self.service_ref and self.service_ref.ref
            if rec_ref and rec_ref.flags & eServiceReference.isGroup:
                rec_ref = getBestPlayableServiceReference(rec_ref, eServiceReference())
                if not rec_ref:
                    self.log(1, "'get best playable service for group... record' failed")
                    return False

            self.record_service = rec_ref and NavigationInstance.instance.recordService(rec_ref)

            if not self.record_service:
                self.log(1, "'record service' failed")
                return False

            if self.repeated:
                epgcache = eEPGCache.getInstance()
                queryTime = self.begin + (self.end - self.begin) / 2
                evt = epgcache.lookupEventTime(rec_ref, queryTime)
                if evt:
                    self.description = evt.getShortDescription()
                    event_id = evt.getEventId()
                else:
                    event_id = -1
            else:
                event_id = self.eit
                if event_id is None:
                    event_id = -1

            prep_res = self.record_service.prepare(
                self.Filename + ".ts",
                self.begin,
                self.end,
                event_id,
                self.name.replace("\n", ""),
                self.description.replace("\n", ""),
                " ".join(self.tags),
            )
            if prep_res:
                if prep_res == -255:
                    self.log(4, "failed to write meta information")
                else:
                    self.log(2, "'prepare' failed: error %d" % prep_res)
                NavigationInstance.instance.stopRecordService(self.record_service)
                self.record_service = None
                return False
            return True
Example #29
0
	def playService(self, ref, checkParentalControl = True, forceRestart = False):
		oldref = self.currentlyPlayingServiceReference
		if ref and oldref and ref == oldref and not forceRestart:
			print "ignore request to play already running service(1)"
			return 0
		print "playing", ref and ref.toString()
		if path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.getValue() == '1':
			try:
				if ref.toString().find('0:0:0:0:0:0:0:0:0') == -1:
					signal = 1
				else:
					signal = 0
				f = open("/proc/stb/lcd/symbol_signal", "w")
				f.write(str(signal))
				f.close()
			except:
				f = open("/proc/stb/lcd/symbol_signal", "w")
				f.write("0")
				f.close()
		elif path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.getValue() == '0':
			f = open("/proc/stb/lcd/symbol_signal", "w")
			f.write("0")
			f.close()

		if ref is None:
			self.stopService()
			return 0
		if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
			if ref.flags & eServiceReference.isGroup:
				if not oldref:
					oldref = eServiceReference()
				playref = getBestPlayableServiceReference(ref, oldref)
				print "playref", playref
				if playref and oldref and playref == oldref and not forceRestart:
					print "ignore request to play already running service(2)"
					return 0
				if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
					self.stopService()
					return 0
			else:
				playref = ref
			if self.pnav:
				self.pnav.stopService()
				self.currentlyPlayingServiceReference = playref
				self.currentlyPlayingServiceOrGroup = ref
				InfoBarInstance = InfoBar.instance
				if InfoBarInstance is not None:
					InfoBarInstance.servicelist.servicelist.setCurrent(ref)
				if self.pnav.playService(playref):
					print "Failed to start", playref
					self.currentlyPlayingServiceReference = None
					self.currentlyPlayingServiceOrGroup = None
				return 0
		else:
			self.stopService()
		return 1
Example #30
0
def getStream(session, request, m3ufile):
	if "ref" in request.args:
		sRef=unquote(unquote(request.args["ref"][0]).decode('utf-8', 'ignore')).encode('utf-8')
	else:
		sRef = ""

	currentServiceRef = None
	if m3ufile == "streamcurrent.m3u":
		currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		sRef = currentServiceRef.toString()

	if sRef.startswith("1:134:"):
		if currentServiceRef is None:
			currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		if currentServiceRef is None:
			currentServiceRef = eServiceReference()
		ref = getBestPlayableServiceReference(eServiceReference(sRef), currentServiceRef)
		if ref is None:
			sRef = ""
		else:
			sRef = ref.toString()

	name = "stream"
	# #EXTINF:-1,%s\n adding back to show service name in programs like VLC
	progopt = ''
	if "name" in request.args:
		name = request.args["name"][0]
		if config.OpenWebif.service_name_for_stream.value:
			progopt="#EXTINF:-1,%s\n" % name

	portNumber = config.OpenWebif.streamport.value
	info = getInfo()
	model = info["model"]
	transcoder_port = None
	if model in ("solo2", "duo2", "solose", "vusolo2", "vuduo2", "vusolose", "hd2400", "xpeedlx3", "gbquad", "gbquadplus"):
		try:
			transcoder_port = int(config.plugins.transcodingsetup.port.value)
		except StandardError:
			#Transcoding Plugin is not installed or your STB does not support transcoding
			transcoder_port = None
		if "device" in request.args :
			if request.args["device"][0] == "phone" :
				portNumber = 8002

	if "port" in request.args:
		portNumber = request.args["port"][0]

	# When you use EXTVLCOPT:program in a transcoded stream, VLC does not play stream
	if config.OpenWebif.service_name_for_stream.value and sRef != '' and portNumber != transcoder_port:
		progopt="%s#EXTVLCOPT:program=%d\n" % (progopt, int(sRef.split(':')[3],16))

	response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:%s/%s\n" % (progopt,request.getRequestHostname(), portNumber, sRef)
	request.setHeader('Content-Type', 'application/text')
	return response
def getStream(session, request, m3ufile):
	if "ref" in request.args:
		sRef=unquote(unquote(request.args["ref"][0]).decode('utf-8', 'ignore')).encode('utf-8')
	else:
		sRef = ""

	currentServiceRef = None
	if m3ufile == "streamcurrent.m3u":
		currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		sRef = currentServiceRef.toString()

	if sRef.startswith("1:134:"):
		if currentServiceRef is None:
			currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		if currentServiceRef is None:
			currentServiceRef = eServiceReference()
		ref = getBestPlayableServiceReference(eServiceReference(sRef), currentServiceRef)
		if ref is None:
			sRef = ""
		else:
			sRef = ref.toString()

	name = "stream"
	# #EXTINF:-1,%s\n adding back to show service name in programs like VLC
	progopt = ''
	if "name" in request.args:
		name = request.args["name"][0]
		if config.OpenWebif.service_name_for_stream.value:
			progopt="#EXTINF:-1,%s\n" % name

	portNumber = config.OpenWebif.streamport.value
	info = getInfo()
	model = info["model"]
	transcoder_port = None
	if model in ("solo2", "duo2", "solose", "vusolo2", "vuduo2", "vusolose", "hd2400", "xpeedlx3", "gbquad", "gbquadplus"):
		try:
			transcoder_port = int(config.plugins.transcodingsetup.port.value)
		except StandardError:
			#Transcoding Plugin is not installed or your STB does not support transcoding
			transcoder_port = None
		if "device" in request.args :
			if request.args["device"][0] == "phone" :
				portNumber = 8002

	if "port" in request.args:
		portNumber = request.args["port"][0]

	# When you use EXTVLCOPT:program in a transcoded stream, VLC does not play stream
	if config.OpenWebif.service_name_for_stream.value and sRef != '' and portNumber != transcoder_port:
		progopt="%s#EXTVLCOPT:program=%d\n" % (progopt, int(sRef.split(':')[3],16))

	response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:%s/%s\n" % (progopt,request.getRequestHostname(), portNumber, sRef)
	request.setHeader('Content-Type', 'application/text')
	return response
Example #32
0
	def _addBouquetTempServiceRefMap(self, bouquet, tempServiceRefMap):
		serviceHandler = eServiceCenter.getInstance()
		servicelist = serviceHandler.list(bouquet)
		if servicelist is not None:
			for sref in servicelist.getContent("R"):
				if sref.flags & eServiceReference.isGroup:
					sref = getBestPlayableServiceReference(sref, eServiceReference())
				if sref and not (sref.flags & self.SERVICE_FLAG_MASK):
					# Unroll tuple(sref.getUnsignedData(i) for i in range(8))
					# for extra speed...
					srefId = (sref.type, sref.getUnsignedData(0), sref.getUnsignedData(1), sref.getUnsignedData(2), sref.getUnsignedData(3), sref.getUnsignedData(4), sref.getUnsignedData(5), sref.getUnsignedData(6), sref.getUnsignedData(7), sref.getPath())
					tempServiceRefMap[srefId][sref.getName()] = sref
Example #33
0
	def recordService(self, ref, simulate=False, type=pNavigation.isUnknownRecording):
		service = None
		if not simulate: print "recording service: %s" % (str(ref))
		if isinstance(ref, ServiceReference.ServiceReference):
			ref = ref.ref
		if ref:
			if ref.flags & eServiceReference.isGroup:
				ref = getBestPlayableServiceReference(ref, eServiceReference(), simulate)
			service = ref and self.pnav and self.pnav.recordService(ref, simulate, type)
			if service is None:
				print "record returned non-zero"
		return service
	def playService(self, service):
		# PiPServiceRelation support
		piprelationservice = self.pipServiceRelation.get(service.toString(),None)
		if piprelationservice is not None:
			 service = eServiceReference(piprelationservice)
		if service and (service.flags & eServiceReference.isGroup):
			ref = getBestPlayableServiceReference(service, eServiceReference())
		else:
			ref = service
		self.pipservice = eServiceCenter.getInstance().play(ref)
		if self.pipservice and not self.pipservice.setTarget(1):
			self.pipservice.start()
			self.currService = ref
Example #35
0
	def recordService(self, ref, simulate=False):
		service = None
		if isinstance(ref, ServiceReference.ServiceReference):
			ref = ref.ref
		if not simulate:
			print "[Navigation] recording service:", (ref and ref.toString())
		if ref:
			if ref.flags & eServiceReference.isGroup:
				ref = getBestPlayableServiceReference(ref, eServiceReference(), simulate)
			service = ref and self.pnav and self.pnav.recordService(ref, simulate)
			if service is None:
				print "[Navigation] record returned non-zero"
		return service
Example #36
0
	def playService(self, service):
		# PiPServiceRelation support
		piprelationservice = self.pipServiceRelation.get(service.toString(),None)
		if piprelationservice is not None:
			 service = eServiceReference(piprelationservice)
		if service and (service.flags & eServiceReference.isGroup):
			ref = getBestPlayableServiceReference(service, eServiceReference())
		else:
			ref = service
		self.pipservice = eServiceCenter.getInstance().play(ref)
		if self.pipservice and not self.pipservice.setTarget(1):
			self.pipservice.start()
			self.currService = ref
Example #37
0
	def recordService(self, ref, simulate=False):
		service = None
		if isinstance(ref, ServiceReference.ServiceReference):
			ref = ref.ref
		if not simulate:
			print "[Navigation] recording service:", (ref and ref.toString())
		if ref:
			if ref.flags & eServiceReference.isGroup:
				ref = getBestPlayableServiceReference(ref, eServiceReference(), simulate)
			service = ref and self.pnav and self.pnav.recordService(ref, simulate)
			if service is None:
				print "[Navigation] record returned non-zero"
		return service
Example #38
0
 def recordService(self, ref, simulate = False):
     service = None
     if not simulate:
         print 'recording service: %s' % str(ref)
     if isinstance(ref, ServiceReference.ServiceReference):
         ref = ref.ref
     if ref:
         if ref.flags & eServiceReference.isGroup:
             ref = getBestPlayableServiceReference(ref, eServiceReference(), simulate)
         service = ref and self.pnav and self.pnav.recordService(ref, simulate)
         if service is None:
             print 'record returned non-zero'
     return service
Example #39
0
 def playService(self, service):
     if service and (service.flags & eServiceReference.isGroup):
         ref = getBestPlayableServiceReference(service, eServiceReference())
     else:
         ref = service
     if ref and ref.toString() != self.currentPiP:
         self.pipservice = eServiceCenter.getInstance().play(ref)
         if self.pipservice and not self.pipservice.setTarget(1):
             self.pipservice.start()
             self.currentPiP = ref.toString()
         else:
             self.pipservice = None
             self.currentPiP = ""
Example #40
0
	def playService(self, service):
		if service and (service.flags & eServiceReference.isGroup):
			ref = getBestPlayableServiceReference(service, eServiceReference())
		else:
			ref = service
		if ref and ref.toString() != self.currentPiP:
			self.pipservice = eServiceCenter.getInstance().play(ref)
			if self.pipservice and not self.pipservice.setTarget(1):
				self.pipservice.start()
				self.currentPiP = ref.toString()
			else:
				self.pipservice = None
				self.currentPiP = ""
Example #41
0
    def tryPrepare(self):
        if self.justplay:
            return True
        else:
            self.calculateFilename()
            rec_ref = self.service_ref and self.service_ref.ref
            if rec_ref and rec_ref.flags & eServiceReference.isGroup:
                rec_ref = getBestPlayableServiceReference(
                    rec_ref, eServiceReference())
                if not rec_ref:
                    self.log(
                        1,
                        "'get best playable service for group... record' failed"
                    )
                    return False

            self.record_service = rec_ref and NavigationInstance.instance.recordService(
                rec_ref)

            if not self.record_service:
                self.log(1, "'record service' failed")
                return False

            if self.repeated:
                epgcache = eEPGCache.getInstance()
                queryTime = self.begin + (self.end - self.begin) / 2
                evt = epgcache.lookupEventTime(rec_ref, queryTime)
                if evt:
                    self.description = evt.getShortDescription()
                    event_id = evt.getEventId()
                else:
                    event_id = -1
            else:
                event_id = self.eit
                if event_id is None:
                    event_id = -1

            prep_res = self.record_service.prepare(
                self.Filename + ".ts", self.begin, self.end, event_id,
                self.name.replace("\n", ""),
                self.description.replace("\n", ""), ' '.join(self.tags))
            if prep_res:
                if prep_res == 255:
                    self.log(4, "failed to write meta information")
                else:
                    self.log(2, "'prepare' failed: error %d" % prep_res)
                NavigationInstance.instance.stopRecordService(
                    self.record_service)
                self.record_service = None
                return False
            return True
Example #42
0
	def playService(self, service):
		if service and (service.flags & eServiceReference.isGroup):
			ref = getBestPlayableServiceReference(service, eServiceReference())
		else:
			ref = service
		if ref:
			self.pipservice = eServiceCenter.getInstance().play(ref)
			if self.pipservice and not self.pipservice.setTarget(1):
				self.pipservice.start()
				self.currentService = service
				return True
			else:
				self.pipservice = None
		return False
Example #43
0
	def playService(self, service):
		if service and (service.flags & eServiceReference.isGroup):
			ref = getBestPlayableServiceReference(service, eServiceReference())
		else:
			ref = service
		if ref:
			self.pipservice = eServiceCenter.getInstance().play(ref)
			if self.pipservice and not self.pipservice.setTarget(1):
				self.pipservice.start()
				self.currentService = service
				return True
			else:
				self.pipservice = None
		return False
Example #44
0
	def addServices(self, fromList, toList, channelIds):
		for scanservice in fromList:
			service = eServiceReference(scanservice.sref)
			if (service.flags & eServiceReference.isGroup):
				service = getBestPlayableServiceReference(eServiceReference(scanservice.sref), eServiceReference())
			if not service or not service.valid() or service.type != eServiceReference.idDVB or (service.flags & (eServiceReference.isMarker|eServiceReference.isDirectory)):
				continue
			channelID = '%08x%04x%04x' % (
				service.getUnsignedData(4), # NAMESPACE
				service.getUnsignedData(2), # TSID
				service.getUnsignedData(3), # ONID
			)
			if channelID not in channelIds:
				toList.append(scanservice)
				channelIds.append(channelID)
Example #45
0
	def recordService(self, ref, simulate=False):
		service = None
		if not simulate:
			print("recording service: %s" % (str(ref)))
		if isinstance(ref, ServiceReference.ServiceReference):
			ref = ref.ref
		if ref:
			if ref.flags & eServiceReference.isGroup:
				ref = getBestPlayableServiceReference(ref, eServiceReference(), simulate)
			service = ref and self.pnav and self.pnav.recordService(ref, simulate)
			if service is None:
				if simulate:
					print("simulate recording service: %s failed" % (str(ref)))
				print("record returned non-zero")
		return service
Example #46
0
 def playService(self, service, playAudio):
     print '  ---PLAY-->   ', service, playAudio
     if service and service.flags & eServiceReference.isGroup:
         ref = getBestPlayableServiceReference(service, eServiceReference())
     else:
         ref = service
     if ref:
         self.pipservice = eServiceCenter.getInstance().play(ref)
         if self.pipservice and not self.pipservice.setTarget(
                 self.decoderIdx):
             self.setQpipMode(True, playAudio)
             self.pipservice.start()
             self.currentService = service
             return True
         self.pipservice = None
     return False
Example #47
0
	def playService(self, service, playAudio):
		print "  ---PLAY-->   ",service,playAudio
		if service and (service.flags & eServiceReference.isGroup):
			ref = getBestPlayableServiceReference(service, eServiceReference())
		else:
			ref = service
		if ref:
			self.pipservice = eServiceCenter.getInstance().play(ref)
			if self.pipservice and not self.pipservice.setTarget(self.decoderIdx):
				self.setQpipMode(True, playAudio)
				self.pipservice.start()
				self.currentService = service
				return True
			else:
				self.pipservice = None
		return False
Example #48
0
def getStream(session, request, m3ufile):

    if "ref" in request.args:
        sRef = unquote(unquote(request.args["ref"][0]).decode("utf-8", "ignore")).encode("utf-8")
    else:
        sRef = ""

    currentServiceRef = None
    if m3ufile == "streamcurrent.m3u":
        currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
        sRef = currentServiceRef.toString()

    if sRef.startswith("1:134:"):
        if currentServiceRef is None:
            currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
        if currentServiceRef is None:
            currentServiceRef = eServiceReference()
        ref = getBestPlayableServiceReference(eServiceReference(sRef), currentServiceRef)
        if ref is None:
            sRef = ""
        else:
            sRef = ref.toString()

    name = "stream"
    if "name" in request.args:
        name = request.args["name"][0]
        # #EXTINF:-1,%s\n  remove not compatiple with old api
    progopt = ""
    if config.OpenWebif.service_name_for_stream.value and sRef != "":
        progopt = "#EXTVLCOPT:program=%d\n" % (int(sRef.split(":")[3], 16))
    portNumber = config.OpenWebif.streamport.value
    info = getInfo()
    model = info["model"]
    if model in ("solo2", "duo2", "Sezam Marvel", "Xpeed LX3", "gbquad", "gbquadplus"):
        if "device" in request.args:
            if request.args["device"][0] == "phone":
                portNumber = config.plugins.transcodingsetup.port.value
        if "port" in request.args:
            portNumber = request.args["port"][0]
    response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:%s/%s\n" % (
        progopt,
        request.getRequestHostname(),
        portNumber,
        sRef,
    )
    request.setHeader("Content-Type", "application/text")
    return response
Example #49
0
 def playService(self, ref, checkParentalControl=True, forceRestart=False):
     oldref = self.currentlyPlayingServiceReference
     if ref and oldref and ref == oldref and not forceRestart:
         print "ignore request to play already running service(1)"
         return 0
     print "playing", ref and ref.toString()
     if ref is None:
         self.stopService()
         return 0
     InfoBarInstance = InfoBar.instance
     if not checkParentalControl or parentalControl.isServicePlayable(
             ref, boundFunction(self.playService,
                                checkParentalControl=False)):
         if ref.flags & eServiceReference.isGroup:
             if not oldref:
                 oldref = eServiceReference()
             playref = getBestPlayableServiceReference(ref, oldref)
             print "playref", playref
             if playref and oldref and playref == oldref and not forceRestart:
                 print "ignore request to play already running service(2)"
                 return 0
             if not playref or (
                     checkParentalControl
                     and not parentalControl.isServicePlayable(
                         playref,
                         boundFunction(self.playService,
                                       checkParentalControl=False))):
                 self.stopService()
                 return 0
         else:
             playref = ref
         if self.pnav:
             self.pnav.stopService()
             self.currentlyPlayingServiceReference = playref
             self.currentlyPlayingServiceOrGroup = ref
             if InfoBarInstance is not None:
                 InfoBarInstance.servicelist.servicelist.setCurrent(ref)
             if self.pnav.playService(playref):
                 print "Failed to start", playref
                 self.currentlyPlayingServiceReference = None
                 self.currentlyPlayingServiceOrGroup = None
             return 0
     elif oldref:
         InfoBarInstance.servicelist.servicelist.setCurrent(oldref)
     return 1
Example #50
0
def playService(self, service):
	current_service = service
	n_service = self.pipServiceRelation.get(service.toString(), None)
	if n_service is not None:
		service = eServiceReference(n_service)
	if service and (service.flags & eServiceReference.isGroup):
		ref = getBestPlayableServiceReference(service, eServiceReference())
	else:
		ref = service
	if ref:
		self.pipservice = eServiceCenter.getInstance().play(ref)
		if self.pipservice and not self.pipservice.setTarget(1):
			self.pipservice.start()
			self.currentService = current_service
			return True
		else:
			self.pipservice = None
	return False
Example #51
0
 def playService(self, service):
     if service and (service.flags & eServiceReference.isGroup):
         ref = getBestPlayableServiceReference(service, eServiceReference())
     else:
         ref = service
     if ref:
         self.pipservice = eServiceCenter.getInstance().play(ref)
         if self.pipservice and not self.pipservice.setTarget(1):
             self.pipservice.start()
             self.currentService = service
             self["SlaveService"].newService(service)
             self.fb_size_video = []
             if self.need_fb_workaround:
                 self.resetFBsize()
             return True
         else:
             self.pipservice = None
     return False
Example #52
0
def playService(self, service):
	current_service = service
	n_service = self.pipServiceRelation.get(service.toString(),None)
	if n_service is not None:
		service = eServiceReference(n_service)
	if service and (service.flags & eServiceReference.isGroup):
		ref = getBestPlayableServiceReference(service, eServiceReference())
	else:
		ref = service
	if ref:
		self.pipservice = eServiceCenter.getInstance().play(ref)
		if self.pipservice and not self.pipservice.setTarget(1):
			self.pipservice.start()
			self.currentService = current_service
			return True
		else:
			self.pipservice = None
	return False
Example #53
0
	def playService(self, ref, checkParentalControl = True, forceRestart = False):
		oldref = self.currentlyPlayingServiceReference
		if ref and oldref and ref == oldref and not forceRestart:
			print "ignore request to play already running service(1)"
			return 0
		if config.ParentalControl.moviepinactive.value and ref:
			path = ref.getPath()
			if path is not None and isinstance(path, str):
				path = os_path.split(path)[0]
				path = os_path.realpath(path)
				path = os_path.abspath(path)
				if not path.endswith('/'):
					path = path + '/'
				protect = config.movielist.moviedirs_config.getConfigValue(path, "protect")
				if not parentalControlFolder.configInitialized:
					parentalControlFolder.getConfigValues()
				if protect == 1 and not parentalControlFolder.sessionPinCached:
					print "ignore request to play already due to parental control"
					self.stopService()
					return 1
		print "playing service.."
		if ref is None:
			self.stopService()
			return 0
		if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
			if ref.flags & eServiceReference.isGroup:
				if not oldref:
					oldref = eServiceReference()
				playref = getBestPlayableServiceReference(ref, oldref)
				print "playref", playref
				if playref and oldref and playref == oldref and not forceRestart:
					print "ignore request to play already running service(2)"
					return 0
				if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
					self.stopService()
					return 0
			else:
				playref = ref
			if self.pnav and not self.pnav.playService(playref):
				self.currentlyPlayingServiceReference = playref
				return 0
		else:
			self.stopService()
		return 1
Example #54
0
    def program_seek_vps_multiple_start(self):
        if self.program_seek_vps_multiple_started == 0:
            self.program_seek_vps_multiple_started = time()

            self.rec_ref = self.timer.service_ref and self.timer.service_ref.ref
            if self.rec_ref and self.rec_ref.flags & eServiceReference.isGroup:
                self.rec_ref = getBestPlayableServiceReference(
                    self.rec_ref, eServiceReference())
            elif self.rec_ref is None:
                self.program_seek_vps_multiple_started = -1
                return

            if self.demux == -1:
                stream = self.timer.record_service.stream()
                if stream:
                    streamdata = stream.getStreamingData()
                    if (streamdata and ('demux' in streamdata)):
                        self.demux = streamdata['demux']
                    else:
                        self.program_seek_vps_multiple_started = -1
                        return

            sid = self.rec_ref.getData(1)
            tsid = self.rec_ref.getData(2)
            onid = self.rec_ref.getData(3)
            demux = "/dev/dvb/adapter0/demux" + str(self.demux)

            if self.timer.vpsplugin_time is not None and self.found_pdc:
                day = strftime("%d", localtime(self.timer.vpsplugin_time))
                month = strftime("%m", localtime(self.timer.vpsplugin_time))
                hour = strftime("%H", localtime(self.timer.vpsplugin_time))
                minute = strftime("%M", localtime(self.timer.vpsplugin_time))
                cmd = vps_exe + " " + demux + " 4 " + str(onid) + " " + str(
                    tsid) + " " + str(sid) + " " + str(
                        self.timer.eit
                    ) + " 0 " + day + " " + month + " " + hour + " " + minute
            else:
                cmd = vps_exe + " " + demux + " 5 " + str(onid) + " " + str(
                    tsid) + " " + str(sid) + " " + str(self.timer.eit) + " 0"

            self.program_seek_vps_multiple.execute(cmd)

            self.timer.log(0, "[VPS] seek another events with same PDC-Time")
Example #55
0
 def addServices(self, fromList, toList, channelIds):
     for scanservice in fromList:
         service = eServiceReference(scanservice.sref)
         if (service.flags & eServiceReference.isGroup):
             service = getBestPlayableServiceReference(
                 eServiceReference(scanservice.sref), eServiceReference())
         if not service or not service.valid(
         ) or service.type != eServiceReference.idDVB or (
                 service.flags &
             (eServiceReference.isMarker | eServiceReference.isDirectory)):
             continue
         channelID = '%08x%04x%04x' % (
             service.getUnsignedData(4),  # NAMESPACE
             service.getUnsignedData(2),  # TSID
             service.getUnsignedData(3),  # ONID
         )
         if channelID not in channelIds:
             toList.append(scanservice)
             channelIds.append(channelID)
def getPlayableServices(sRef, sRefPlaying):
    if sRef == "":
        sRef = '%s FROM BOUQUET "bouquets.tv" ORDER BY bouquet' % (service_types_tv)

    services = []
    servicecenter = eServiceCenter.getInstance()
    servicelist = servicecenter.list(eServiceReference(sRef))
    servicelist2 = servicelist and servicelist.getContent("S") or []

    for service in servicelist2:
        if not int(service.split(":")[1]) & 512:  # 512 is hidden service on sifteam image. Doesn't affect other images
            service2 = {}
            service2["servicereference"] = service
            service2["isplayable"] = (
                getBestPlayableServiceReference(eServiceReference(service), eServiceReference(sRefPlaying)) != None
            )
            services.append(service2)

    return {"result": True, "services": services}
def getStream(session, request, m3ufile):

	if "ref" in request.args:
		sRef=unquote(unquote(request.args["ref"][0]).decode('utf-8', 'ignore')).encode('utf-8')
	else:
		sRef = ""
	
	currentServiceRef = None
	if m3ufile == "streamcurrent.m3u":
		currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		sRef = currentServiceRef.toString() 
	
	if sRef.startswith("1:134:"):
		if currentServiceRef is None:
			currentServiceRef = session.nav.getCurrentlyPlayingServiceReference()
		if currentServiceRef is None:
			currentServiceRef = eServiceReference()
		ref = getBestPlayableServiceReference(eServiceReference(sRef), currentServiceRef)
		if ref is None:
			sRef = ""
		else:
			sRef = ref.toString()

	name = "stream"
	if "name" in request.args:
		name = request.args["name"][0]
	# #EXTINF:-1,%s\n  remove not compatiple with old api
	progopt = ''
	if config.OpenWebif.service_name_for_stream.value and sRef != '':
		progopt="#EXTVLCOPT:program=%d\n" % (int(sRef.split(':')[3],16))
	portNumber = config.OpenWebif.streamport.value
	info = getInfo()
	model = info["model"]
	if model in ("solo2", "duo2", "Sezam Marvel", "Xpeed LX3", "gbquad", "gbquadplus"):
		if "device" in request.args :
			if request.args["device"][0] == "phone" :
				portNumber = config.plugins.transcodingsetup.port.value
		if "port" in request.args:
			portNumber = request.args["port"][0]
	response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:%s/%s\n" % (progopt,request.getRequestHostname(), portNumber, sRef)
	request.setHeader('Content-Type', 'application/text')
	return response