Ejemplo n.º 1
0
    def getTimerEventList(self):
        # eventslist.dayname, eventslist.datum, eventslist.starttime, eventslist.endtime,
        # channel.channel, eventslist.status, events.title, events.description, eventslist.id_events
        try:
            sql.cur.execute("SELECT SQLITE_VERSION()")
        except Exception:
            sys.exc_clear()
            try:
                sql.connect()
            except Exception:
                return

        myList = None
        myList = []

        self["name"].setText("Timer Auswahl")

        rows = sql.getEventsTimer(self.id_events, "ASC", getCurrentTimestamp())
        resultCount = len(rows)
        if resultCount > 0:
            for row in rows:
                myList.append(row)

            self["handlung"].setText("Titel: \t" + myList[0][6] + "\nBeschreibung: \t" + myList[0][7])
            self.streamMenuList.setList(map(self.skyAnytimerListEntry, sorted(myList, key=lambda stime: stime[2])))
            # self['filmliste'].moveToIndex = 0
        try:
            self["head"].setText("%s Sendetermine" % str(resultCount))
        except Exception:
            sys.exc_clear()
Ejemplo n.º 2
0
	def getSkyGuidePages(self,data=None):
		msg_log = "building urls"
		print msg_log
		self.addLog(msg_log)
		
		# settimestamp to preskip outdated events
		# later we will check again with time now()
		self.check_time = getCurrentTimestamp() + 900 #assume our check could takes 15 min
		
		self.is_done = False
		self.pages = None
		self.pages = []
		self.SKY_CHANNEL_LIST = "http://www.skygo.sky.de/epgd/web/channelList"
		self.SKY_GO_BASE = "http://www.skygo.sky.de"
		self.SEARCH_BASE = "http://www.skygo.sky.de/epgd/web/eventList"
		self.SEARCH_DAY = "06.03.2013" # just en example, real day(s) is set below
		
		# We want active channles only, or the full list?
		if config.plugins.skyrecorder.only_active_channels and config.plugins.skyrecorder.only_active_channels.value:
			channelid_list_sky = sql.getChannelIdSky(True)
			self.SEARCH_CHANNEL_IDS = ','.join(str(i) for i in channelid_list_sky)
		else:
			channelid_list_sky = sql.getChannelIdSky(False)
			self.SEARCH_CHANNEL_IDS = ','.join(str(i) for i in channelid_list_sky)
		
		if not self.SEARCH_CHANNEL_IDS or len(self.SEARCH_CHANNEL_IDS) < 1:
			self.IS_RUNNING = False
			self.checkDone("keine Sender aktiviert", set_stamp = True)
			return
		
		# build day list - we want to scan n-days at once
		self.guide_days_to_search = []
		future_days = 2 # means 1 day
		if config.plugins.skyrecorder.guide_days_to_scan and config.plugins.skyrecorder.guide_days_to_scan.value:
			future_days = int(config.plugins.skyrecorder.guide_days_to_scan.value)
			future_days += 1 # because of range n -1
		
		# include day yesterday in list, but only if we are looking for new broadcasts
		if config.plugins.skyrecorder.only_new_events and config.plugins.skyrecorder.only_new_events.value:
			self.guide_days_to_search.append((datetime.date.today() - datetime.timedelta(days=1)).strftime("%d.%m.%Y"))
		# include day today in list 
		self.guide_days_to_search.append(datetime.date.today().strftime("%d.%m.%Y"))
		
		for delta_day in range(1,future_days):
			self.guide_days_to_search.append((datetime.date.today() + datetime.timedelta(days=delta_day)).strftime("%d.%m.%Y"))
		
		maxpage = None
		self.maxpage = len(self.guide_days_to_search)
		self.cur_pagenr = 0
		
		# go
		self.startGuideDownload()
Ejemplo n.º 3
0
	def checkDone(self, msg_log="", set_stamp = True):
		# we are done
		# store our latest update timestamp for the wakeMeUp function
		if set_stamp:
			config.plugins.skyrecorder.lastchecked.value = getCurrentTimestamp()
			config.plugins.skyrecorder.lastchecked.save()
			configfile.save()
			
			# delete outdated entries we needed for events which were tagged "is_new" in the past
			n = sql.deleteEvents(getCurrentTimestamp())
			if n == 1:
				msg = "[skyrecorder] {0} Eintrag geloescht".format(n)
			else:
				msg = "[skyrecorder] {0} Eintraege geloescht".format(n)
			print msg
			self.addLog(msg)
			
		print msg_log
		self.addLog(msg_log)
		
		# if we want automatic recordtimerentries, we start here
		if config.plugins.skyrecorder.auto_recordtimer_entries and config.plugins.skyrecorder.auto_recordtimer_entries.value:
			time.sleep(1)
			SkyRunAutocheck(self.session)	
Ejemplo n.º 4
0
    def changeTimer(self):
        self.startReadLog()

        if config.plugins.skyrecorder.autoupdate_database.value:
            print "[skyrecorder] checktimer."
            try:
                if SkyGetTvGuide.instance.refreshTimer:
                    SkyGetTvGuide.instance.refreshTimer.stop()
                    SkyGetTvGuide.instance.refreshTimer = None
                    SkyGetTvGuide.instance.refreshTimer = eTimer()
                    SkyGetTvGuide.instance.refreshTimer.callback.append(
                        SkyGetTvGuide.instance.start)
                    interval = int(config.plugins.skyrecorder.next_update.value
                                   ) - getCurrentTimestamp()
                    if interval > 10 and interval <= 5184000:  # 10 seconds buffer, but lower or equal than 1 day
                        #SkyGetTvGuide.instance.timerinterval = interval * 1000 # milleseconds
                        #SkyGetTvGuide.instance.refreshTimer.start(SkyGetTvGuide.instance.timerinterval)
                        SkyGetTvGuide.instance.timerinterval = interval
                        SkyGetTvGuide.instance.refreshTimer.startLongTimer(
                            SkyGetTvGuide.instance.timerinterval)

                else:
                    #config.plugins.skyrecorder.lastchecked.value = getCurrentTimestamp()
                    #config.plugins.skyrecorder.lastchecked.save()
                    #configfile.save()
                    SkyGetTvGuide(
                        self.session, False
                    )  # do not start it right now, we can run it manually, if we want to
            except AttributeError:
                # was not running - start it now
                #config.plugins.skyrecorder.lastchecked.value = getCurrentTimestamp()
                #config.plugins.skyrecorder.lastchecked.save()
                #configfile.save()
                SkyGetTvGuide(
                    self.session, False
                )  # do not start it right now, we can run it manually, if we want to
        else:
            try:
                if SkyGetTvGuide.instance.refreshTimer:
                    SkyGetTvGuide.instance.refreshTimer.stop()
                    SkyGetTvGuide.instance.refreshTimer = None
            except AttributeError:
                # was never running
                print "[skyrecorder] changeTimer did nothing"
Ejemplo n.º 5
0
	def changeTimer(self):
		self.startReadLog()
		
		if config.plugins.skyrecorder.autoupdate_database.value:
			print "[skyrecorder] checktimer."
			try:
				if SkyGetTvGuide.instance.refreshTimer:
					SkyGetTvGuide.instance.refreshTimer.stop()
					SkyGetTvGuide.instance.refreshTimer = None
					SkyGetTvGuide.instance.refreshTimer = eTimer()
					SkyGetTvGuide.instance.refreshTimer.callback.append(SkyGetTvGuide.instance.start)
					interval = int(config.plugins.skyrecorder.next_update.value) - getCurrentTimestamp()
					if interval > 10 and interval <= 5184000: # 10 seconds buffer, but lower or equal than 1 day
						#SkyGetTvGuide.instance.timerinterval = interval * 1000 # milleseconds
						#SkyGetTvGuide.instance.refreshTimer.start(SkyGetTvGuide.instance.timerinterval)
						SkyGetTvGuide.instance.timerinterval = interval
						SkyGetTvGuide.instance.refreshTimer.startLongTimer(SkyGetTvGuide.instance.timerinterval)
					
				else:
					#config.plugins.skyrecorder.lastchecked.value = getCurrentTimestamp()
					#config.plugins.skyrecorder.lastchecked.save()
					#configfile.save()
					SkyGetTvGuide(self.session, False) # do not start it right now, we can run it manually, if we want to
			except AttributeError:
				# was not running - start it now
				#config.plugins.skyrecorder.lastchecked.value = getCurrentTimestamp()
				#config.plugins.skyrecorder.lastchecked.save()
				#configfile.save()
				SkyGetTvGuide(self.session, False) # do not start it right now, we can run it manually, if we want to
		else:
			try:
				if SkyGetTvGuide.instance.refreshTimer:
					SkyGetTvGuide.instance.refreshTimer.stop()
					SkyGetTvGuide.instance.refreshTimer = None
			except AttributeError:
				# was never running
				print "[skyrecorder] changeTimer did nothing"
Ejemplo n.º 6
0
	def start(self,oneShot=False):
		self.oneShot = oneShot
		
		if not checkForInternet():
			return
		
		# update refresh timerinterval now
		if config.plugins.skyrecorder.autoupdate_database.value:
			try:
				if self.refreshTimer:
					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()
					
					interval = int(config.plugins.skyrecorder.next_update.value) - getCurrentTimestamp()
					self.refreshTimer.stop()
					self.refreshTimer.startLongTimer(interval)
			except Exception:
				sys.exc_clear()
		
		
		if self.oneShot or config.plugins.skyrecorder.autoupdate_database.value:
			msg_log = "[skyrecorder] aktualisiere Datenbank..."
			print msg_log
			self.addLog(msg_log)

			try:
				sql.cur.execute('SELECT SQLITE_VERSION()')
			except Exception:
				sys.exc_clear()
				try:
					sql.connect()
				except Exception:
					self.IS_RUNNING = False
					return
			
			# first clean up old files
			msg_log = "[skyrecorder] entferne alte Eintraege..."
			print msg_log
			self.addLog(msg_log)
			n = sql.deleteEvents(getCurrentTimestamp())
			if n == 1:
				msg_log = "[skyrecorder] {0} Eintrag geloescht".format(n)
			else:
				msg_log = "[skyrecorder] {0} Eintraege geloescht".format(n)
			print msg_log
			self.addLog(msg_log)
			
			self.IS_RUNNING = True
			
			try:
				sql.cur.execute('SELECT SQLITE_VERSION()')
			except Exception:
				sys.exc_clear()
				try:
					sql.connect()
				except Exception:
					self.IS_RUNNING = False
					return
			
			self.station_id = -1
			self.last_station_idx = 0
			self.SkyStations = self.getSkyStations()
			self.maxStationLoop = len(self.SkyStations) - 1
			# start here
			try:
				self.getCookie()
			except Exception, e:
				msg_log = "ERROR: {0}".format(e)
				print msg_log
				self.addLog(msg_log)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
		try:
			id_events = sql.addEvent(entry["title"], entry["description"], entry["sky_id"],entry["image"], entry["id_channel"], entry["id_genre"])
		except Exception, e:
			self.addLog(e)
		
		if not id_events:
			print "Fehler: addEvent"
			self.addLog("Fehler: addEvent")
		else:
			pass
		
		# if the starttime is in the past, continue to then next event
		tstamp_start = self.unixtime(entry["datum"], entry["starttime"])
		tstamp_end = self.unixtime(entry["datum"], entry["endtime"])
		skytime = self.skyTimeStamp(entry["starttime"], tstamp_start, tstamp_end)
		if getCurrentTimestamp() > skytime[0] and entry["is_new"] != 1: # need to add outdated is_new events to get newer ones later
			self.addLog("[skyrecorder] ignored entry idx {0}/{1}, event is outdated".format(idx + 1, max_idx + 1))
			
		elif sql.checkAdded(entry["title"], entry["description"], entry["id_channel"], entry["id_genre"]):
			# let us ignore finished recordnigs - we do not want new braodcast dates fot those events
			self.addLog("[skyrecorder] ignored entry idx {0}/{1}, event is already in table added".format(idx + 1, max_idx + 1))
		
		else:
			datum = None
			datum = getDateFromTimestamp(skytime[0])
			
			dayname = None
			dayname = getDayOfTheWeek(skytime[0], False)
			
			id_eventslist = None
			id_eventdetails = None
Ejemplo n.º 9
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))