def addTimer(session,
             serviceref,
             begin,
             end,
             name,
             description,
             disabled,
             justplay,
             afterevent,
             dirname,
             tags,
             repeated,
             vpsinfo=None,
             logentries=None,
             eit=0):
    serviceref = unquote(serviceref)
    rt = session.nav.RecordTimer

    print "mao1", dirname

    if not dirname:
        dirname = preferredTimerPath()

    print "mao2", dirname

    try:
        timer = RecordTimerEntry(ServiceReference(serviceref),
                                 begin,
                                 end,
                                 name,
                                 description,
                                 eit,
                                 disabled,
                                 justplay,
                                 afterevent,
                                 dirname=dirname,
                                 tags=tags)

        timer.repeated = repeated

        if logentries:
            timer.log_entries = logentries

        conflicts = rt.record(timer)
        if conflicts:
            errors = []
            for conflict in conflicts:
                errors.append(conflict.name)

            return {
                "result": False,
                "message":
                "Conflicting Timer(s) detected! %s" % " / ".join(errors)
            }
    except Exception, e:
        print e
        return {"result": False, "message": "Could not add timer '%s'!" % name}
def addTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterevent, dirname, tags, repeated, vpsinfo=None, logentries=None, eit=0, always_zap=-1):
	serviceref = unquote(serviceref)
	rt = session.nav.RecordTimer

	print "mao1", dirname

	if not dirname:
		dirname = preferredTimerPath()

	print "mao2", dirname

	try:
		timer = RecordTimerEntry(
			ServiceReference(serviceref),
			begin,
			end,
			name,
			description,
			eit,
			disabled,
			justplay,
			afterevent,
			dirname=dirname,
			tags=tags)

		timer.repeated = repeated

		if logentries:
			timer.log_entries = logentries

		conflicts = rt.record(timer)
		if conflicts:
			errors = []
			for conflict in conflicts:
				errors.append(conflict.name)

			return {
				"result": False,
				"message": _("Conflicting Timer(s) detected! %s") % " / ".join(errors)
			}
		#VPS
		if vpsinfo is not None:
			timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
			timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
			timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

		if always_zap <> -1:
			if hasattr(timer,"always_zap"):
				timer.always_zap = always_zap == 1

	except Exception, e:
		print e
		return {
			"result": False,
			"message": _("Could not add timer '%s'!") % name
		}
def addTimer(
    session,
    serviceref,
    begin,
    end,
    name,
    description,
    disabled,
    justplay,
    afterevent,
    dirname,
    tags,
    repeated,
    logentries=None,
    eit=0,
):
    serviceref = unquote(serviceref)
    rt = session.nav.RecordTimer

    print "mao1", dirname

    if not dirname:
        dirname = preferredTimerPath()

    print "mao2", dirname

    try:
        timer = RecordTimerEntry(
            ServiceReference(serviceref),
            begin,
            end,
            name,
            description,
            eit,
            disabled,
            justplay,
            afterevent,
            dirname=dirname,
            tags=tags,
        )

        timer.repeated = repeated

        if logentries:
            timer.log_entries = logentries

        conflicts = rt.record(timer)
        if conflicts:
            errors = []
            for conflict in conflicts:
                errors.append(conflict.name)

            return {"result": False, "message": "Conflicting Timer(s) detected! %s" % " / ".join(errors)}
    except Exception, e:
        print e
        return {"result": False, "message": "Could not add timer '%s'!" % name}
Beispiel #4
0
	def UPDT(self, args):
		# <id> <settings>
		args = args.split(None, 1)
		if len(args) != 2:
			payload = "%d argument error" % (CODE_SYNTAX,)
			return self.sendLine(payload)

		try:
			timerId = int(args[0])
		except ValueError:
			payload = "%d argument error" % (CODE_SYNTAX,)
			return self.sendLine(payload)

		list = self.getTimerList()

		if timerId < 1:
			payload = "%d argument error" % (CODE_SYNTAX,)
			return self.sendLine(payload)

		if len(list) >= timerId: oldTimer = list[timerId - 1]
		else: oldTimer = None

		try:
			flags, channelid, datestring, beginstring, endstring, priority, lifetime, name, description = args[1].split(':')
			flags = int(flags)
			service_ref = ServiceReference(self.channelList[int(channelid)-1])
			datestruct = strptime(datestring, '%Y-%m-%d')
			timestruct = strptime(beginstring, '%H%M')
			begin = mktime((datestruct.tm_year, datestruct.tm_mon, datestruct.tm_mday, timestruct.tm_hour, timestruct.tm_min, 0, datestruct.tm_wday, datestruct.tm_yday, -1))
			timestruct = strptime(endstring, '%H%M')
			end = mktime((datestruct.tm_year, datestruct.tm_mon, datestruct.tm_mday, timestruct.tm_hour, timestruct.tm_min, 0, datestruct.tm_wday, datestruct.tm_yday, -1))
			del datestruct, timestruct
		except ValueError as e:
			payload = "%d argument error" % (CODE_SYNTAX,)
			return self.sendLine(payload)
		except KeyError as e:
			payload = "%d argument error" % (CODE_SYNTAX,)
			return self.sendLine(payload)

		if end < begin: end += 86400 # Add 1 day, beware - this is evil and might not work correctly due to dst
		timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled=flags & 1 == 0)
		if oldTimer:
			recordTimer.removeEntry(oldTimer)
			timer.justplay = oldTimer.justplay
			timer.afterEvent = oldTimer.afterEvent
			timer.dirname = oldTimer.dirname
			timer.tags = oldTimer.tags
			timer.log_entries = oldTimer.log_entries

		conflict = recordTimer.record(timer)
		if conflict is None:
			return self.sendTimerLine(timer, timerId, last=True)
		else:
			payload = "%d timer conflict detected, original timer lost." % (CODE_ERR_LOCAL,)
			return self.sendLine(payload)
def addTimer(session,
             serviceref,
             begin,
             end,
             name,
             description,
             disabled,
             justplay,
             afterevent,
             dirname,
             tags,
             repeated,
             recordingtype,
             vpsinfo=None,
             logentries=None,
             eit=0,
             always_zap=-1,
             pipzap=-1,
             allow_duplicate=1,
             autoadjust=-1):
    rt = session.nav.RecordTimer

    if not dirname:
        dirname = preferredTimerPath()

    #  IPTV Fix
    serviceref = serviceref.replace('%253a', '%3a')

    try:
        timer = RecordTimerEntry(ServiceReference(serviceref),
                                 begin,
                                 end,
                                 name,
                                 description,
                                 eit,
                                 disabled,
                                 justplay,
                                 afterevent,
                                 dirname=dirname,
                                 tags=tags)

        timer.repeated = repeated

        if logentries:
            timer.log_entries = logentries

        conflicts = rt.record(timer)
        if conflicts:
            errors = []
            conflictinfo = []
            for conflict in conflicts:
                errors.append(conflict.name)
                conflictinfo.append({
                    "serviceref":
                    str(conflict.service_ref),
                    "servicename":
                    conflict.service_ref.getServiceName().replace(
                        '\xc2\x86', '').replace('\xc2\x87', ''),
                    "name":
                    conflict.name,
                    "begin":
                    conflict.begin,
                    "end":
                    conflict.end,
                    "realbegin":
                    strftime(_("%d.%m.%Y %H:%M"),
                             (localtime(float(conflict.begin)))),
                    "realend":
                    strftime(_("%d.%m.%Y %H:%M"),
                             (localtime(float(conflict.end))))
                })

            return {
                "result":
                False,
                "message":
                _("Conflicting Timer(s) detected! %s") % " / ".join(errors),
                "conflicts":
                conflictinfo
            }
        # VPS
        if vpsinfo is not None:
            timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
            timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
            timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

        if always_zap != -1:
            if hasattr(timer, "always_zap"):
                timer.always_zap = always_zap == 1
            if hasattr(timer, "zapbeforerecord"):
                timer.zapbeforerecord = always_zap == 1

        if hasattr(timer, "autoadjust"):
            if autoadjust == -1:
                autoadjust = config.recording.adjust_time_to_event.value and 1 or 0
            autoadjust = autoadjust

        if hasattr(timer, "allow_duplicate"):
            allow_duplicate = allow_duplicate

        if pipzap != -1:
            if hasattr(timer, "pipzap"):
                timer.pipzap = pipzap == 1

        if recordingtype:
            timer.descramble = {
                "normal": True,
                "descrambled": True,
                "scrambled": False,
            }[recordingtype]
            timer.record_ecm = {
                "normal": False,
                "descrambled": True,
                "scrambled": True,
            }[recordingtype]

    except Exception as e:
        print(str(e))
        return {
            "result": False,
            "message": _("Could not add timer '%s'!") % name
        }

    return {"result": True, "message": _("Timer '%s' added") % name}
Beispiel #6
0
def addTimer(session,
             serviceref,
             begin,
             end,
             name,
             description,
             disabled,
             justplay,
             afterevent,
             dirname,
             tags,
             repeated,
             vpsinfo=None,
             logentries=None,
             eit=0,
             always_zap=-1):
    rt = session.nav.RecordTimer

    if not dirname:
        dirname = preferredTimerPath()

    try:
        timer = RecordTimerEntry(ServiceReference(serviceref),
                                 begin,
                                 end,
                                 name,
                                 description,
                                 eit,
                                 disabled,
                                 justplay,
                                 afterevent,
                                 dirname=dirname,
                                 tags=tags)

        timer.repeated = repeated

        if logentries:
            timer.log_entries = logentries

        conflicts = rt.record(timer)
        if conflicts:
            errors = []
            conflictinfo = []
            for conflict in conflicts:
                errors.append(conflict.name)
                conflictinfo.append({
                    "serviceref":
                    str(conflict.service_ref),
                    "servicename":
                    mangle_epg_text(conflict.service_ref.getServiceName()),
                    "name":
                    conflict.name,
                    "begin":
                    conflict.begin,
                    "end":
                    conflict.end,
                    "realbegin":
                    strftime("%d.%m.%Y %H:%M",
                             (localtime(float(conflict.begin)))),
                    "realend":
                    strftime("%d.%m.%Y %H:%M",
                             (localtime(float(conflict.end))))
                })

            return {
                "result":
                False,
                "message":
                _("Conflicting Timer(s) detected! %s") % " / ".join(errors),
                "conflicts":
                conflictinfo
            }
        # VPS
        if vpsinfo is not None:
            timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
            timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
            timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

        if always_zap != -1:
            if hasattr(timer, "always_zap"):
                timer.always_zap = always_zap == 1

    except Exception as e:
        print e
        return {
            "result": False,
            "message": _("Could not add timer '%s'!") % name
        }

    return {"result": True, "message": _("Timer '%s' added") % name}
  def editTimer(self, param):
    print "[WebComponents.Timer] editTimer"

    #OK first we need to parse all of your Parameters
    #For some of them (like afterEvent or justplay) we can use default values
    #for others (the serviceReference or the Begin/End time of the timer
    #we have to quit if they are not set/have illegal values

    if 'serviceref' in param:
      param['sRef'] = str(param['serviceref'])

    if 'sRef' not in param:
      return ( False, "Missing Parameter: sRef" )
    service_ref = ServiceReference(param['sRef'])

    repeated = int(param.get('repeated') or 0)

    if 'begin' not in param:
      return ( False, "Missing Parameter: begin" )
    begin = int(float(param['begin']))

    if 'end' not in param:
      return ( False, "Missing Parameter: end" )
    end = int(float(param['end']))

    tm = time()
    if tm <= begin:
      pass
    elif tm > begin and tm < end and repeated == 0:
      begin = time()
    elif repeated == 0:
      return ( False, "Illegal Parameter value for Parameter begin : '%s'" % begin )

    if 'name' not in param:
      return ( False, "Missing Parameter: name" )
    name = param['name']

    if 'description' not in param:
      return ( False, "Missing Parameter: description" )
    description = param['description'].replace("\n", " ")

    disabled = False #Default to: Enabled
    if 'disabled' in param:
      if param['disabled'] == "1":
        disabled = True
      else:
        #TODO - maybe we can give the user some useful hint here
        pass

    justplay = False #Default to: Record
    if 'justplay' in param:
      if param['justplay'] == "1":
        justplay = True

    afterEvent = 3 #Default to Afterevent: Auto
    if 'afterevent' in param:
      if (param['afterevent'] == "0") or (param['afterevent'] == "1") or (param['afterevent'] == "2"):
        afterEvent = int(param['afterevent'])

    dirname = preferredTimerPath()
    if 'dirname' in param and param['dirname']:
      dirname = param['dirname']

    tags = []
    if 'tags' in param and param['tags']:
      tags = unescape(param['tags']).split(' ')

    delold = 0
    if 'deleteOldOnSave' in param:
      delold = int(param['deleteOldOnSave'])

    #Try to edit an existing Timer
    if delold:
      if 'channelOld' in param and param['channelOld']:
        channelOld = ServiceReference(param['channelOld'])
      else:
        return ( False, "Missing Parameter: channelOld" )
      # We do need all of the following Parameters, too, for being able of finding the Timer.
      # Therefore so we can neither use default values in this part nor can we
      # continue if a parameter is missing
      if 'beginOld' not in param:
        return ( False, "Missing Parameter: beginOld" )
      beginOld = int(param['beginOld'])

      if 'endOld' not in param:
        return ( False, "Missing Parameter: endOld" )
      endOld = int(param['endOld'])

      #let's try to find the timer
      try:
        for timer in self.__recordtimer.timer_list + self.__recordtimer.processed_timers:
          if str(timer.service_ref) == str(channelOld):
            if int(timer.begin) == beginOld:
              if int(timer.end) == endOld:                
                #we've found the timer we've been searching for                
                
                #Delete the old entry
                self.__recordtimer.removeEntry(timer)
                old = timer
                
                timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled, justplay, afterEvent, dirname=dirname, tags=tags)
                timer.repeated = repeated
                timer.log_entries = old.log_entries                
                
                timer.processRepeated()                
                #send the changed timer back to enigma2 and hope it's good
                
                conflicts = self.__recordtimer.record(timer)
                if conflicts is None:
                  print "[WebComponents.Timer] editTimer: Timer changed!"
                  return ( True, "Timer '%s' changed" %(timer.name) )
                else:
                  print "[WebComponents.Timer] editTimer conflicting Timers: %s" %(conflicts)
                  msg = ""
                  for timer in conflicts:
                    msg = "%s / %s" %(msg, timer.name)        
                    
                  return (False, "Conflicting Timer(s) detected! %s" %(msg)) 

      except Exception:
        #obviously some value was not good, return an error
        return ( False, "Changing the timer for '%s' failed!" % name )

      return ( False, "Could not find timer '%s' with given start and end time!" % name )

    #Try adding a new Timer

    try:
      #Create a new instance of recordtimerentry
      timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled, justplay, afterEvent, dirname=dirname, tags=tags)
      timer.repeated = repeated
      #add the new timer
      conflicts = self.__recordtimer.record(timer)
      if conflicts is None:
        return ( True, "Timer '%s' added" %(timer.name) )
      else:
        print "[WebComponents.Timer] editTimer conflicting Timers: %s" %(conflicts)
        msg = ""
        for timer in conflicts:
          msg = "%s / %s" %(msg, timer.name)        
          
        return (False, "Conflicting Timer(s) detected! %s" %(msg)) 
        
    except Exception, e:
      #something went wrong, most possibly one of the given paramater-values was wrong
      print "[WebComponents.Timer] editTimer exception: %s" %(e)
      return ( False, "Could not add timer '%s'!" % name )
Beispiel #8
0
    def editTimer(self, param):
        print "[WebComponents.Timer] editTimer"

        #OK first we need to parse all of your Parameters
        #For some of them (like afterEvent or justplay) we can use default values
        #for others (the serviceReference or the Begin/End time of the timer
        #we have to quit if they are not set/have illegal values

        if 'sRef' not in param:
            return (False, "Missing Parameter: sRef")
        service_ref = ServiceReference(param['sRef'])

        repeated = int(param.get('repeated') or 0)

        if 'begin' not in param:
            return (False, "Missing Parameter: begin")
        begin = int(float(param['begin']))

        if 'end' not in param:
            return (False, "Missing Parameter: end")
        end = int(float(param['end']))

        tm = time()
        if tm <= begin:
            pass
        elif tm > begin and tm < end and repeated == 0:
            begin = time()
        elif repeated == 0:
            return (False,
                    "Illegal Parameter value for Parameter begin : '%s'" %
                    begin)

        if 'name' not in param:
            return (False, "Missing Parameter: name")
        name = param['name']

        if 'description' not in param:
            return (False, "Missing Parameter: description")
        description = param['description'].replace("\n", " ")

        disabled = False  #Default to: Enabled
        if 'disabled' in param:
            if param['disabled'] == "1":
                disabled = True
            else:
                #TODO - maybe we can give the user some useful hint here
                pass

        justplay = False  #Default to: Record
        if 'justplay' in param:
            if param['justplay'] == "1":
                justplay = True

        afterEvent = 3  #Default to Afterevent: Auto
        if 'afterevent' in param:
            if (param['afterevent'] == "0") or (param['afterevent']
                                                == "1") or (param['afterevent']
                                                            == "2"):
                afterEvent = int(param['afterevent'])

        dirname = preferredTimerPath()
        if 'dirname' in param and param['dirname']:
            dirname = param['dirname']

        tags = []
        if 'tags' in param and param['tags']:
            tags = unescape(param['tags']).split(' ')

        delold = 0
        if 'deleteOldOnSave' in param:
            delold = int(param['deleteOldOnSave'])

        #Try to edit an existing Timer
        if delold:
            if 'channelOld' in param and param['channelOld']:
                channelOld = ServiceReference(param['channelOld'])
            else:
                return (False, "Missing Parameter: channelOld")
            # We do need all of the following Parameters, too, for being able of finding the Timer.
            # Therefore so we can neither use default values in this part nor can we
            # continue if a parameter is missing
            if 'beginOld' not in param:
                return (False, "Missing Parameter: beginOld")
            beginOld = int(param['beginOld'])

            if 'endOld' not in param:
                return (False, "Missing Parameter: endOld")
            endOld = int(param['endOld'])

            #let's try to find the timer
            try:
                for timer in self.recordtimer.timer_list + self.recordtimer.processed_timers:
                    if str(timer.service_ref) == str(channelOld):
                        if int(timer.begin) == beginOld:
                            if int(timer.end) == endOld:
                                #we've found the timer we've been searching for

                                #Delete the old entry
                                self.recordtimer.removeEntry(timer)
                                old = timer

                                timer = RecordTimerEntry(service_ref,
                                                         begin,
                                                         end,
                                                         name,
                                                         description,
                                                         0,
                                                         disabled,
                                                         justplay,
                                                         afterEvent,
                                                         dirname=dirname,
                                                         tags=tags)
                                timer.repeated = repeated
                                timer.log_entries = old.log_entries

                                timer.processRepeated()
                                #send the changed timer back to enigma2 and hope it's good

                                conflicts = self.recordtimer.record(timer)
                                if conflicts is None:
                                    print "[WebComponents.Timer] editTimer: Timer changed!"
                                    return (True, "Timer '%s' changed" %
                                            (timer.name))
                                else:
                                    print "[WebComponents.Timer] editTimer conflicting Timers: %s" % (
                                        conflicts)
                                    msg = ""
                                    for timer in conflicts:
                                        msg = "%s / %s" % (msg, timer.name)

                                    return (
                                        False,
                                        "Conflicting Timer(s) detected! %s" %
                                        (msg))

            except Exception:
                #obviously some value was not good, return an error
                return (False, "Changing the timer for '%s' failed!" % name)

            return (
                False,
                "Could not find timer '%s' with given start and end time!" %
                name)

        #Try adding a new Timer

        try:
            #Create a new instance of recordtimerentry
            timer = RecordTimerEntry(service_ref,
                                     begin,
                                     end,
                                     name,
                                     description,
                                     0,
                                     disabled,
                                     justplay,
                                     afterEvent,
                                     dirname=dirname,
                                     tags=tags)
            timer.repeated = repeated
            #add the new timer
            conflicts = self.recordtimer.record(timer)
            if conflicts is None:
                return (True, "Timer '%s' added" % (timer.name))
            else:
                print "[WebComponents.Timer] editTimer conflicting Timers: %s" % (
                    conflicts)
                msg = ""
                for timer in conflicts:
                    msg = "%s / %s" % (msg, timer.name)

                return (False, "Conflicting Timer(s) detected! %s" % (msg))

        except Exception, e:
            #something went wrong, most possibly one of the given paramater-values was wrong
            print "[WebComponents.Timer] editTimer exception: %s" % (e)
            return (False, "Could not add timer '%s'!" % name)
Beispiel #9
0
    def addTimer(
        session,
        serviceref,
        begin,
        end,
        name,
        description,
        disabled,
        justplay,
        afterevent,
        dirname,
        tags,
        repeated,
        logentries=None,
        eit=0,
    ):

        recordHandler = NavigationInstance.instance.RecordTimer

        msgTimeout = config.plugins.skyrecorder.msgtimeout.value

        if not dirname:
            try:
                dirname = config.plugins.skyrecorder.anytimefolder.value
            except Exception:
                dirname = preferredTimerPath()

        print "mao1", dirname

        try:
            timer = RecordTimerEntry(
                ServiceReference(serviceref),
                begin,
                end,
                name,
                description,
                eit,
                disabled,
                justplay,
                afterevent,
                dirname=dirname,
                tags=tags,
            )

            timer.repeated = repeated

            if logentries:
                timer.log_entries = logentries
                print "rrgggg"

            conflicts = recordHandler.record(timer)
            if conflicts:
                errors = []
                for conflict in conflicts:
                    errors.append(conflict.name)

                print "duuuupppppppeeeeee"
                return {"result": False, "message": "Conflicting Timer(s) detected! %s" % " / ".join(errors)}
        except Exception, e:
            print "adupppeee"
            print e
            return {"result": False, "message": "Could not add timer '%s'!" % name}
Beispiel #10
0
def addTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterevent, dirname, tags, repeated, vpsinfo=None, logentries=None, eit=0, always_zap=-1):
	rt = session.nav.RecordTimer

	if not dirname:
		dirname = preferredTimerPath()

	try:
		timer = RecordTimerEntry(
			ServiceReference(serviceref),
			begin,
			end,
			name,
			description,
			eit,
			disabled,
			justplay,
			afterevent,
			dirname=dirname,
			tags=tags)

		timer.repeated = repeated

		if logentries:
			timer.log_entries = logentries

		conflicts = rt.record(timer)
		if conflicts:
			errors = []
			conflictinfo = []
			for conflict in conflicts:
				errors.append(conflict.name)
				conflictinfo.append({
					"serviceref": str(conflict.service_ref),
					"servicename": conflict.service_ref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''),
					"name": conflict.name,
					"begin" : conflict.begin,
					"end" : conflict.end,
					"realbegin":strftime("%d.%m.%Y %H:%M", (localtime(float(conflict.begin)))),
					"realend":strftime("%d.%m.%Y %H:%M", (localtime(float(conflict.end))))
				})

			return {
				"result": False,
				"message": _("Conflicting Timer(s) detected! %s") % " / ".join(errors),
				"conflicts" : conflictinfo
			}
		#VPS
		if vpsinfo is not None:
			timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
			timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
			timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

		if always_zap <> -1:
			if hasattr(timer,"always_zap"):
				timer.always_zap = always_zap == 1

	except Exception, e:
		print e
		return {
			"result": False,
			"message": _("Could not add timer '%s'!") % name
		}
Beispiel #11
0
        if end < begin:
            end += 86400  # Add 1 day, beware - this is evil and might not work correctly due to dst
        timer = RecordTimerEntry(service_ref,
                                 begin,
                                 end,
                                 name,
                                 description,
                                 0,
                                 disabled=flags & 1 == 0)
        if oldTimer:
            recordTimer.removeEntry(oldTimer)
            timer.justplay = oldTimer.justplay
            timer.afterEvent = oldTimer.afterEvent
            timer.dirname = oldTimer.dirname
            timer.tags = oldTimer.tags
            timer.log_entries = oldTimer.log_entries

        conflict = recordTimer.record(timer)
        if conflict is None:
            return self.sendTimerLine(timer, timerId, last=True)
        else:
            payload = "%d timer conflict detected, original timer lost." % (
                CODE_ERR_LOCAL, )
            return self.sendLine(payload)

    def NEWT(self, args):
        self.UPDT("999999999 " + args)

    def MODT(self, args):
        # <id> on | off | <settings>
        args = args.split(None, 1)
	def addTimer(serviceref, begin, end, name, description, eit, disabled, dirname, vpsSettings, tags, logentries=None):

		recordHandler = NavigationInstance.instance.RecordTimer
		# config.plugins.serienRec.seriensubdir
		# if not dirname:
		#	try:
		#		dirname = config.plugins.serienRec.savetopath.value
		#	except Exception:
		#		dirname = preferredTimerPath()
		try:
			try:
				timer = RecordTimerEntry(
					ServiceReference(serviceref),
					begin,
					end,
					name,
					description,
					eit,
					disabled=disabled,
					justplay=config.plugins.serienRec.justplay.value,
					zapbeforerecord=config.plugins.serienRec.zapbeforerecord.value,
					justremind=config.plugins.serienRec.justremind.value,
					afterEvent=int(config.plugins.serienRec.afterEvent.value),
					dirname=dirname)
			except Exception:
				sys.exc_clear()

				timer = RecordTimerEntry(
					ServiceReference(serviceref),
					begin,
					end,
					name,
					description,
					eit,
					disabled,
					config.plugins.serienRec.justplay.value | config.plugins.serienRec.justremind.value,
					afterEvent=int(config.plugins.serienRec.afterEvent.value),
					dirname=dirname,
					tags=None)

			timer.repeated = 0

			# Add tags
			timerTags = timer.tags[:]
			timerTags.append('SerienRecorder')
			if len(tags) != 0:
				timerTags.extend(tags)
			timer.tags = timerTags

			# If eit = 0 the VPS plugin won't work properly for this timer, so we have to disable VPS in this case.
			if SerienRecorder.VPSPluginAvailable and eit is not 0:
				timer.vpsplugin_enabled = vpsSettings[0]
				timer.vpsplugin_overwrite = timer.vpsplugin_enabled and (not vpsSettings[1])

			if logentries:
				timer.log_entries = logentries

			timer.log(0, "[SerienRecorder] Timer angelegt")

			conflicts = recordHandler.record(timer)
			if conflicts:
				errors = []
				for conflict in conflicts:
					errors.append(conflict.name)

				return {
					"result": False,
					"message": "In Konflikt stehende Timer vorhanden! %s" % " / ".join(errors)
				}
		except Exception, e:
			print "[%s] <%s>" % (__name__, e)
			return {
				"result": False,
				"message": "Timer konnte nicht angelegt werden '%s'!" % e
			}
Beispiel #13
0
		except ValueError, e:
			payload = "%d argument error" % (CODE_SYNTAX,)
			return self.sendLine(payload)
		except KeyError, e:
			payload = "%d argument error" % (CODE_SYNTAX,)
			return self.sendLine(payload)

		if end < begin: end += 86400 # Add 1 day, beware - this is evil and might not work correctly due to dst
		timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled=flags & 1 == 0)
		if oldTimer:
			recordTimer.removeEntry(oldTimer)
			timer.justplay = oldTimer.justplay
			timer.afterEvent = oldTimer.afterEvent
			timer.dirname = oldTimer.dirname
			timer.tags = oldTimer.tags
			timer.log_entries = oldTimer.log_entries

		conflict = recordTimer.record(timer)
		if conflict is None:
			return self.sendTimerLine(timer, timerId, last=True)
		else:
			payload = "%d timer conflict detected, original timer lost." % (CODE_ERR_LOCAL,)
			return self.sendLine(payload)

	def NEWT(self, args):
		self.UPDT("999999999 " + args)

	def MODT(self, args):
		# <id> on | off | <settings>
		args = args.split(None, 1)
		if len(args) != 2: