示例#1
0
    def getTimersList():

        recordHandler = NavigationInstance.instance.RecordTimer

        entry = None
        timers = []
        sky_chlist = buildSkyChannellist()

        for timer in recordHandler.timer_list:
            if timer and timer.service_ref and timer.eit is not None:

                location = "NULL"
                channel = "NULL"
                recordedfile = "NULL"
                if timer.dirname:
                    location = timer.dirname
                channel = getChannelByRef(sky_chlist, str(timer.service_ref))
                if channel:
                    recordedfile = getRecordFilename(timer.name, timer.description, timer.begin, channel)
                timers.append(
                    {
                        "title": timer.name,
                        "description": timer.description,
                        "id_channel": "NULL",
                        "channel": channel,
                        "id_genre": "NULL",
                        "begin": timer.begin,
                        "end": timer.end,
                        "serviceref": timer.service_ref,
                        "location": location,
                        "recordedfile": recordedfile,
                        "tags": timer.tags,
                    }
                )
        return timers
示例#2
0
	def __init__(self, session, last_index):
		self.session = session
		self.last_index = last_index
		
		path = "%s/skins/%s/screen_channel_editor.xml" % (getPluginPath(), config.plugins.skyrecorder.anytime_skin.value)
		with open(path, "r") as f:
			self.skin = f.read()
			f.close()
			
		Screen.__init__(self, session)
		
		pluginName = config.plugins.skyrecorder.pluginname.value
		contentSize = config.plugins.skyrecorder.contentsize.value
		
		self.sky_chlist = buildSkyChannellist()

		self["actions"]  = ActionMap(["OkCancelActions", "ShortcutActions", "ColorActions", "MenuActions"], {
			"ok"    : self.keyOK,
			"cancel": self.keyCancel
		}, -1)
		
		self['title'] = Label(pluginName)
		self['head'] = Label("Skiplist")
		
		self.channellist = []
		self.streamMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.streamMenuList.l.setFont(0, gFont('Regular', contentSize))
		self.streamMenuList.l.setItemHeight(25)
		self['channeledit'] = self.streamMenuList
		
		self.sky_skipwords_path = "/usr/lib/enigma2/python/Plugins/Extensions/skyrecorder/sky_skipwords"
		self.sky_skipwords_path_tmp = "/usr/lib/enigma2/python/Plugins/Extensions/skyrecorder/sky_skipwords.tmp"
				
		self.onShown.append(self.readChannellist)
    def __init__(self, session, last_index):
        self.session = session
        self.last_index = last_index

        path = "%s/skins/%s/screen_channel_editor.xml" % (
            getPluginPath(), config.plugins.skyrecorder.anytime_skin.value)
        with open(path, "r") as f:
            self.skin = f.read()
            f.close()

        Screen.__init__(self, session)

        pluginName = config.plugins.skyrecorder.pluginname.value
        contentSize = config.plugins.skyrecorder.contentsize.value

        self.sky_chlist = buildSkyChannellist()

        self["actions"] = ActionMap(
            [
                "OkCancelActions", "ShortcutActions", "ColorActions",
                "MenuActions"
            ], {
                "ok": self.keyOK,
                "cancel": self.keyCancel,
                "red": self.askDeleteChannels,
                "green": self.askDeleteChannel
            }, -1)

        self.channellist = []
        self.streamMenuList = MenuList([],
                                       enableWrapAround=True,
                                       content=eListboxPythonMultiContent)
        self.streamMenuList.l.setFont(0, gFont('Regular', 32))
        self.streamMenuList.l.setItemHeight(75)
        self['channeledit'] = self.streamMenuList

        self.sky_skipwords_path = "/usr/lib/enigma2/python/Plugins/Extensions/skyrecorder/sky_skipwords"
        self.sky_skipwords_path_tmp = "/usr/lib/enigma2/python/Plugins/Extensions/skyrecorder/sky_skipwords.tmp"

        self.onShown.append(self.readChannellist)
示例#4
0
	def __init__(self, session, oneShot = False):

		# singleton class - needed to call it at sessionstart
		SkyGetTvGuide.instance = self

		self.session = session
		self.oneShot = oneShot
		
		self.IS_RUNNING = False
		
		self.nonHDeventList = nonHDeventList()
		self.sky_chlist = buildSkyChannellist()
		self.agent = getUserAgent()
		self.headers = getHttpHeader()
		self.headersJSON = getHttpHeaderJSON()
		self.headers1 = getHttpHeader1()
		
		# update current agent for the header, too
		self.headers.update({'User-Agent': self.agent})
		self.headers1.update({'User-Agent': self.agent})
		self.headersJSON.update({'User-Agent': self.agent})
		
		self.pluginName = config.plugins.skyrecorder.pluginname.value
		
		self.ck = {}
		self.sky_log_path = "/usr/lib/enigma2/python/Plugins/Extensions/skyrecorder/sky_log"

		if self.oneShot and config.plugins.skyrecorder.autoupdate_database.value:
		
			# do we really need a new update right now?
			checktime = getCurrentTimestamp()
			nextcheck = checktime
			lastcheck = checktime
			try:
				lastcheck = int(config.plugins.skyrecorder.lastchecked.value)
				nextcheck = int(config.plugins.skyrecorder.next_update.value)
			except Exception:
				sys.exc_clear()
			if ((checktime + 300) >= nextcheck) and (lastcheck < nextcheck): # 5 minutes buffer should be ok, because the STB is starting to fast, sometimes
				print "[skyrecorder] timer AutotimerCheck gesetzt"
				
				# be sure we got a new timestamp, even something went wrong
				config.plugins.skyrecorder.lastchecked.value = checktime
				config.plugins.skyrecorder.lastchecked.save()
				# set new wecker for our timer
				if config.plugins.skyrecorder.database_update_time and config.plugins.skyrecorder.database_update_time.value:
					alarm = setWecker(config.plugins.skyrecorder.database_update_time.value, True) # be sure we shift one day
				else:
					alarm = setWecker([6,0], True) # be sure we shift one day
				config.plugins.skyrecorder.next_update.value = alarm
				config.plugins.skyrecorder.next_update.save()
				configfile.save()
				
				# let us start it right now. needed for wakMeUp function
				self.tempTimer = None
				self.tempTimer = eTimer()
				self.tempTimer.callback.append(self.start(self.oneShot))
				self.tempTimer.start(5000, True) # give us some time to breath, before we start
				
		# set the timer for the next update now
		if config.plugins.skyrecorder.autoupdate_database.value:
			self.refreshTimer = None
			self.refreshTimer = eTimer()
			self.refreshTimer.callback.append(self.start)
			if config.plugins.skyrecorder.next_update and config.plugins.skyrecorder.lastchecked:
				interval = int(config.plugins.skyrecorder.next_update.value) - getCurrentTimestamp()
				if interval > 60 and interval <= 5184000: # 60 seconds buffer, but lower or equal than 1 day
					#self.timerinterval = interval * 1000 # milliseconds
					#self.refreshTimer.start(self.timerinterval)
					self.timerinterval = interval
					self.refreshTimer.startLongTimer(self.timerinterval)
示例#5
0
    def __init__(self, session, id_events, id_channel, id_genre):
        self.session = session

        path = "%s/skins/%s/screen_timer_select.xml" % (getPluginPath(), config.plugins.skyrecorder.anytime_skin.value)
        with open(path, "r") as f:
            self.skin = f.read()
            f.close()

        Screen.__init__(self, session)

        self.id_events = str(id_events)
        self.id_channel = id_channel
        self.id_genre = id_genre

        self.nonHDeventList = nonHDeventList()
        self.sky_chlist = buildSkyChannellist()

        self.pluginName = config.plugins.skyrecorder.pluginname.value
        self.contentSize = config.plugins.skyrecorder.contentsize.value

        self["actions"] = ActionMap(
            [
                "OkCancelActions",
                "ShortcutActions",
                "EPGSelectActions",
                "WizardActions",
                "ColorActions",
                "NumberActions",
                "MenuActions",
                "MoviePlayerActions",
            ],
            {
                "ok": self.keyOK,
                "cancel": self.keyCancel,
                "nextBouquet": self.keyPageUp,
                "prevBouquet": self.keyPageDown,
            },
            -1,
        )

        self["title"] = Label(self.pluginName)
        try:
            self["head"] = Label("Sendetermine")
        except Exception:
            sys.exc_clear()
        self["name"] = Label("Timer Auswahl")
        self["handlung"] = Label(" ")
        self["image"] = Pixmap()
        self["image"].hide()

        self["hd"] = Pixmap()
        self["hd"].hide()

        self["169"] = Pixmap()
        self["169"].hide()

        self["dolby"] = Pixmap()
        self["dolby"].hide()

        self["dualch"] = Pixmap()
        self["dualch"].hide()

        self["sub"] = Pixmap()
        self["sub"].hide()

        self.keyLocked = True
        self.streamMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
        self.streamMenuList.l.setFont(0, gFont("Regular", self.contentSize))
        self.streamMenuList.l.setItemHeight(25)
        self["filmliste"] = self.streamMenuList

        self.onLayoutFinish.append(self.getTimerEventList)
示例#6
0
	def __init__(self, session):

		if not config.plugins.skyrecorder.auto_recordtimer_entries:
			return

		self.session = session

		self.sky_chlist = buildSkyChannellist()

		self.ck = {}
		self.sky_log_path = "/usr/lib/enigma2/python/Plugins/Extensions/skyrecorder/sky_log"

		msg_log = "[skyrecorder] starte AutotimerCheck..."
		print msg_log
		self.addLog(msg_log)
		self.my_day_range = None

		try:
			self.my_day_range = config.plugins.skyrecorder.timerdays_allowed.value
		except Exception:
			sys.exc_clear()
			self.my_day_range = ["all"]
		
		dirname = None
		recordings_base_folder = None
		try:
			if config.plugins.skyrecorder.anytimefolder.value:
				recordings_base_folder = config.plugins.skyrecorder.anytimefolder.value
		except Exception:
			sys.exc_clear()
			recordings_base_folder = None
		
		self.pluginName = config.plugins.skyrecorder.pluginname.value
		fromtime = config.plugins.skyrecorder.fromtime.value
		totime = config.plugins.skyrecorder.totime.value
		range_allowed = None
		range_allowed = getEventAllowedRange(int(fromtime),int(totime), self.my_day_range)

		justplay = False
		if config.plugins.skyrecorder.timer_mode.value == "1":
			justplay = True

		filmliste = None
		filmliste = []

		try:
			skipset = sql.getSkipSelect()
		except Exception:
			sys.exc_clear()
			sql.connect()
			skipset = sql.getSkipSelect()
		
		maxParallelTimerLimit = 1000
		if config.plugins.skyrecorder.max_parallel_timers and config.plugins.skyrecorder.max_parallel_timers.value:
			maxParallelTimerLimit = int(config.plugins.skyrecorder.max_parallel_timers.value)
		
		
		# events.id_events, events.title, events.description, events.id_channel,
		# genre.genre, genre.id_genre, eventslist.status, channel.channel,events.image, events.sky_id
		# eventdetails.is_new
		#rows = sql.getEventsMain(channelset,genreset,order="ASC")
		
		# excecute modified sql-function which excludes hidden files
		rows = sql.getEventsMainAutoCheck(order="ASC")
		resultCount = len(rows)
		if resultCount > 0:
			for row in rows:
				filmliste.append(row)

			filmliste = sorted(filmliste, key=lambda stime: stime[7])

		canskip = False
		for event in filmliste:
			
			# only events which are marked as is_new should be added
			if int(event[12]) != 1:
				continue
				
			for skip in skipset:
				if re.match('.*?'+skip, event[1], re.I):
					print "skip word matched"
					canskip = True
					break
			if canskip:
				canskip = False
				continue

			id_events = None
			id_events = event[0]
			id_genre = None
			id_genre = event[5]
			id_channel = None
			id_channel = event[3]
			myList = None
			myList = []

			rows = sql.getEventsTimer(id_events,order="ASC")
			resultCount = len(rows)
			if resultCount < 1:
				continue

			for row in rows:
				myList.append(row)

			myList = sorted(myList, key=lambda stime: stime[2])
			
						
			if recordings_base_folder:
				if not config.plugins.skyrecorder.create_dirtree.value:
					dirname = recordings_base_folder
				else:
					# get our groupfoldername
					a_dir = sql.getGenregroupByGenreId(id_genre)
					if a_dir:
						group_dir = os.path.join(recordings_base_folder, a_dir + "/")
						if not os.path.exists(group_dir):
							try:
								os.makedirs(group_dir, mode=0777)
								dirname = group_dir
							except Exception:
								sys.exc_clear()
						else:
							dirname = group_dir
					
						
			for timerevent in myList:
				datum = timerevent[1]
				starttime = timerevent[2]
				endtime = timerevent[3]
				channel = timerevent[4]
				title = timerevent[6]
				desc = timerevent[7]
				if getCurrentTimestamp() > starttime:
					continue

				# FIXME
				hourmin = None
				hourmin = getTimeFromTimestamp(starttime)
				(std,min) = hourmin.split(':')
				event_day = getDayOfTheWeek(starttime, True)
				#self.addLog("std:" + std + " min:" + min)
				#self.addLog(str(range_allowed[0]) + " " + str(range_allowed[1]))


				if int(std) not in range_allowed[0] or str(event_day) not in range_allowed[1]:
					logtext = "[skyrecorder] skipped, day %s and hour %s is not in range_allowed" % (event_day, int(std))
					self.addLog(logtext)
					print logtext
					continue

				if sql.checkAdded(title.lower(), desc.lower(), id_channel, id_genre): 
					msg_log = "[skyrecorder] already added: %s - %s (%s)" % (title, desc, id_channel)
					print msg_log
					self.addLog(msg_log)
					break

				stb_channel = sql.getChannelFromChannel(channel,stb=True)
				channelref = self.getChannelref(stb_channel)
				if not channelref:
					break
					
				# use settings "margin_before" and "margin_after"
				# for the timers starttime and endtime adjustment
				timer_starttime = starttime - config.plugins.skyrecorder.margin_before.value * 60;
				timer_endtime = endtime + config.plugins.skyrecorder.margin_after.value * 60;
				
				# try to limit recordtimer-entries
				# reload timerlist for every broadcast event/date - neede to be up-to-date
				self.timerList = SkyTimerRec.getTimersList()
				if self.timerList and len(self.timerList) > 0 and maxParallelTimerLimit < 1000:							
					tc = 0
					for t_record in self.timerList:
						if (str(channelref) == str(t_record['serviceref'])) and maxParallelTimerLimit > 1:
							if timer_endtime > int(t_record['begin']):
								if timer_starttime < int(t_record['end']):
									tc += 1
						else:
							# 1 min buffer for events on different channels
							if (timer_endtime + 60) > int(t_record['begin']):
								if (timer_starttime - 60) < int(t_record['end']):
									tc += 1
				
					if tc >= maxParallelTimerLimit:
						continue
					
				# finally try to add record-timer
				# timer-sanitycheck is handled by system-timer itself.				
				result = SkyTimerRec.addTimer(self.session, channelref, timer_starttime, timer_endtime, title, desc, 0, justplay, 3, dirname, None, 0, None, eit=0)
				if result["result"]:

					# added by einfall
					#begin_date = time.strftime("%Y%m%d %H%M", time.localtime(starttime))
					file = getRecordFilename(title,desc,timer_starttime,stb_channel) #"%s - %s - %s.ts" % (begin_date,channel,title)

					# id_added,title,description,id_channel,id_genre,begin,end,serviceref,location,recordedfile
					if not sql.addAdded(title, desc, id_channel, id_genre, timer_starttime, timer_endtime, channelref, dirname, file): 
						logtext = "[skyrecorder] could not add %s %s %s to added table" % (title, desc, stb_channel)
						self.addLog(logtext)
						print logtext

					sql.updateEventListStatus(id_events,starttime,status="True")

					print "[skyrecorder] time config:", fromtime,totime,std
					print "[skyrecorder] added:", datum,starttime,endtime,stb_channel,title
					logtext = "Timer Added: %s %s %s %s %s" % (datum, timer_starttime, timer_endtime, stb_channel, title)
					self.addLog(logtext)
					break
				else:
					print "[skyrecorder] timer error: {0}".format(result["message"])
					self.addLog("[skyrecorder] timer error: {0}".format(result["message"]))
	
		
		# try to sleep again				
		try:
			# go on only if kill deep standby is set
			if config.plugins.skyrecorder.wakeup and config.plugins.skyrecorder.wakeup.value:
				if not Screens.Standby.inStandby and config.plugins.skyrecorder.autoupdate_database.value:
					if str(config.plugins.skyrecorder.after_update.value) == "deepstandby":
						mymsg = "{0}\nDie STB wird jetzt ausgeschaltet.".format(self.pluginName)
						self.session.openWithCallback(self.sleepWell,  MessageBox, _(mymsg), MessageBox.TYPE_YESNO, timeout=30, default=True)
					
					elif str(config.plugins.skyrecorder.after_update.value) == "standby":
						mymsg = "{0}\nDie STB geht jetzt in den Standby-Modus.".format(self.pluginName)
						self.session.openWithCallback(self.sendStandbyNotification,  MessageBox, _(mymsg), MessageBox.TYPE_YESNO, timeout=30, default=True)
		except Exception, e:
			print "[skyrecorder] {0}".format(e)
			self.addLog("[skyrecorder] timer error: {0}".format(e))