def recordNow(session, infinite):
    rt = session.nav.RecordTimer
    serviceref = session.nav.getCurrentlyPlayingServiceReference().toString()

    try:
        event = session.nav.getCurrentService().info().getEvent(0)
    except Exception:
        event = None

    if not event and not infinite:
        return {
            "result": False,
            "message": _("No event found! Not recording!")
        }

    if event:
        (begin, end, name, description, eit) = parseEvent(event)
        begin = time()
        msg = _("Instant record for current Event started")
    else:
        name = "instant record"
        description = ""
        eit = 0

    if infinite:
        begin = time()
        end = begin + 3600 * 10
        msg = _("Infinite Instant recording started")

    timer = RecordTimerEntry(ServiceReference(serviceref),
                             begin,
                             end,
                             name,
                             description,
                             eit,
                             False,
                             False,
                             0,
                             dirname=preferredInstantRecordPath())
    timer.dontSave = True

    if rt.record(timer):
        return {
            "result": False,
            "message": _("Timer conflict detected! Not recording!")
        }
    nt = {
        "serviceref": str(timer.service_ref),
        "servicename": removeBad(timer.service_ref.getServiceName()),
        "eit": timer.eit,
        "name": timer.name,
        "begin": timer.begin,
        "end": timer.end,
        "duration": timer.end - timer.begin
    }

    return {"result": True, "message": msg, "newtimer": nt}
Example #2
0
def getStreamServiceAndEvent(ref):
    sname = "(unknown service)"
    eventname = ""
    if not isinstance(ref, eServiceReference):
        ref = eServiceReference(ref)
    servicereference = ServiceReference(ref)
    if servicereference:
        sname = removeBad(servicereference.getServiceName())
    epg = eEPGCache.getInstance()
    event = epg and epg.lookupEventTime(ref, -1, 0)
    if event:
        eventname = event.getEventName()
    return sname, eventname
Example #3
0
def getStreamServiceAndEvent(ref):
	sname = "(unknown service)"
	eventname = ""
	if not isinstance(ref, eServiceReference):
		ref = eServiceReference(ref)
	servicereference = ServiceReference(ref)
	if servicereference:
		sname = removeBad(servicereference.getServiceName())
	epg = Epg()
	event = epg.getCurrentEvent(ref)
	if event:
		eventname = event.getEventName()
	return sname, eventname
def getTimers(session):
    rt = session.nav.RecordTimer
    epg = Epg()
    timers = []
    for timer in rt.timer_list + rt.processed_timers:
        if hasattr(timer, "wakeup_t"):
            energytimer = timer.wakeup_t or timer.standby_t or timer.shutdown_t or timer.fnc_t != "off" or 0
            if energytimer:
                continue

        descriptionextended = "N/A"
        filename = None
        nextactivation = None
        if timer.eit and timer.service_ref:
            descriptionextended = epg.getEventDescription(
                timer.service_ref, timer.eit)

        try:
            filename = timer.Filename
        except Exception:
            pass

        try:
            nextactivation = timer.next_activation
        except Exception:
            pass

        disabled = 0
        if timer.disabled:
            disabled = 1

        justplay = 0
        if timer.justplay:
            justplay = 1

        if hasattr(timer, "allow_duplicate"):
            allow_duplicate = timer.allow_duplicate and 1 or 0
        else:
            allow_duplicate = 1

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

        if timer.dirname:
            dirname = timer.dirname
        else:
            dirname = "None"

        dontSave = 0
        if timer.dontSave:
            dontSave = 1

        toggledisabled = 1
        if timer.disabled:
            toggledisabled = 0

        toggledisabledimg = "off"
        if timer.disabled:
            toggledisabledimg = "on"

        asrefs = ""
        achannels = GetWithAlternative(str(timer.service_ref), False)
        if achannels:
            asrefs = achannels

        vpsplugin_enabled = False
        vpsplugin_overwrite = False
        vpsplugin_time = -1
        if hasattr(timer, "vpsplugin_enabled"):
            vpsplugin_enabled = True if timer.vpsplugin_enabled else False
        if hasattr(timer, "vpsplugin_overwrite"):
            vpsplugin_overwrite = True if timer.vpsplugin_overwrite else False
        if hasattr(timer, "vpsplugin_time"):
            vpsplugin_time = timer.vpsplugin_time
            if not vpsplugin_time:
                vpsplugin_time = -1

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

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

        isAutoTimer = -1
        if hasattr(timer, "isAutoTimer"):
            if timer.isAutoTimer:
                isAutoTimer = 1
            else:
                isAutoTimer = 0

        if six.PY2:
            descriptionextended = six.text_type(descriptionextended,
                                                'utf_8',
                                                errors='ignore').encode(
                                                    'utf_8', 'ignore')

        recordingtype = "normal"

        if timer.record_ecm:
            recordingtype = "scrambled"
            if timer.descramble:
                recordingtype = "descrambled"

        ice_timer_id = -1
        if hasattr(timer, "ice_timer_id"):
            ice_timer_id = timer.ice_timer_id or -1

        # switch back to old way.
        #fuzzyBegin = ' '.join(str(i) for i in FuzzyTime(timer.begin, inPast = True)[1:])
        #fuzzyEnd = ""
        #if strftime("%Y%m%d", localtime(timer.begin)) == strftime("%Y%m%d", localtime(timer.end)):
        #	fuzzyEnd = FuzzyTime(timer.end)[1]
        #else:
        #	fuzzyEnd = ' '.join(str(i) for i in FuzzyTime(timer.end, inPast = True))

        fuzzyBegin = strftime(_("%d.%m.%Y %H:%M"),
                              (localtime(float(timer.begin))))
        fuzzyEnd = strftime(_("%d.%m.%Y %H:%M"), (localtime(float(timer.end))))

        timers.append({
            "serviceref":
            str(timer.service_ref),
            "servicename":
            removeBad(timer.service_ref.getServiceName()),
            "eit":
            timer.eit,
            "name":
            timer.name,
            "description":
            timer.description,
            "descriptionextended":
            descriptionextended,
            "disabled":
            disabled,
            "begin":
            timer.begin,
            "end":
            timer.end,
            "duration":
            timer.end - timer.begin,
            "startprepare":
            timer.start_prepare,
            "justplay":
            justplay,
            "afterevent":
            timer.afterEvent,
            "dirname":
            dirname,
            "tags":
            " ".join(timer.tags),
            "logentries":
            timer.log_entries,
            "backoff":
            timer.backoff,
            "firsttryprepare":
            timer.first_try_prepare,
            "state":
            timer.state,
            "repeated":
            timer.repeated,
            "dontsave":
            dontSave,
            "cancelled":
            timer.cancelled,
            "toggledisabled":
            toggledisabled,
            "toggledisabledimg":
            toggledisabledimg,
            "filename":
            filename,
            "nextactivation":
            nextactivation,
            "realbegin":
            fuzzyBegin,
            "realend":
            fuzzyEnd,
            "asrefs":
            asrefs,
            "vpsplugin_enabled":
            vpsplugin_enabled,
            "vpsplugin_overwrite":
            vpsplugin_overwrite,
            "vpsplugin_time":
            vpsplugin_time,
            "always_zap":
            always_zap,
            "pipzap":
            pipzap,
            "isAutoTimer":
            isAutoTimer,
            "allow_duplicate":
            allow_duplicate,
            "autoadjust":
            autoadjust,
            "recordingtype":
            recordingtype,
            "ice_timer_id":
            ice_timer_id
        })

    return {"result": True, "timers": timers}
def editTimer(session, serviceref, begin, end, name, description, disabled,
              justplay, afterEvent, dirname, tags, repeated, channelOld,
              beginOld, endOld, recordingtype, vpsinfo, always_zap, pipzap,
              allow_duplicate, autoadjust):
    channelOld_str = ':'.join(str(channelOld).split(':')[:11])
    rt = session.nav.RecordTimer
    for timer in rt.timer_list + rt.processed_timers:
        needed_ref = ':'.join(
            timer.service_ref.ref.toString().split(':')[:11]) == channelOld_str
        if needed_ref and int(timer.begin) == beginOld and int(
                timer.end) == endOld:
            timer.service_ref = ServiceReference(serviceref)
            # TODO: start end time check
            timer.begin = int(float(begin))
            timer.end = int(float(end))
            timer.name = name
            timer.description = description
            # TODO : EIT
            # timer.eit = eit
            timer.disabled = disabled
            timer.justplay = justplay
            timer.afterEvent = afterEvent
            timer.dirname = dirname
            timer.tags = tags
            timer.repeated = repeated
            timer.processRepeated()
            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 pipzap != -1:
                if hasattr(timer, "pipzap"):
                    timer.pipzap = pipzap == 1

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

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

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

            # TODO: multi tuner test
            sanity = TimerSanityCheck(rt.timer_list, timer)
            conflicts = None
            if not sanity.check():
                conflicts = sanity.getSimulTimerList()
                if conflicts is not None:
                    for conflict in conflicts:
                        if conflict.setAutoincreaseEnd(timer):
                            rt.timeChanged(conflict)
                            if not sanity.check():
                                conflicts = sanity.getSimulTimerList()
            if conflicts is None:
                rt.timeChanged(timer)
                return {
                    "result": True,
                    "message": _("Timer '%s' changed") % name
                }
            else:
                errors = []
                conflictinfo = []
                for conflict in conflicts:
                    errors.append(conflict.name)
                    conflictinfo.append({
                        "serviceref":
                        str(conflict.service_ref),
                        "servicename":
                        removeBad(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": _("Timer '%s' not saved while Conflict") % name,
                    "conflicts": conflictinfo
                }

    return {
        "result":
        False,
        "message":
        _("Could not find timer '%s' with given start and end time!") % name
    }
Example #6
0
def getStatusInfo(self):
    # Get Current Volume and Mute Status
    vcontrol = eDVBVolumecontrol.getInstance()
    statusinfo = {
        'volume': vcontrol.getVolume(),
        'muted': vcontrol.isMuted(),
        'transcoding': TRANSCODING,
        'currservice_filename': "",
        'currservice_id': -1,
    }

    # Get currently running Service
    event = None
    serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
    serviceref_string = None
    currservice_station = None
    if serviceref is not None:
        serviceHandler = eServiceCenter.getInstance()
        serviceHandlerInfo = serviceHandler.info(serviceref)

        service = self.session.nav.getCurrentService()
        serviceinfo = service and service.info()
        event = serviceinfo and serviceinfo.getEvent(0)
        serviceref_string = serviceref.toString()
        currservice_station = removeBad(serviceHandlerInfo.getName(serviceref))
    else:
        event = None
        serviceHandlerInfo = None

    if event is not None:
        # (begin, end, name, description, eit)
        curEvent = parseEvent(event)
        begin_timestamp = int(
            curEvent[0]) + (config.recording.margin_before.value * 60)
        end_timestamp = int(
            curEvent[1]) - (config.recording.margin_after.value * 60)
        statusinfo['currservice_name'] = removeBad(curEvent[2])
        statusinfo['currservice_serviceref'] = serviceref_string
        statusinfo['currservice_begin'] = time.strftime(
            "%H:%M", (time.localtime(begin_timestamp)))
        statusinfo['currservice_begin_timestamp'] = begin_timestamp
        statusinfo['currservice_end'] = time.strftime(
            "%H:%M", (time.localtime(end_timestamp)))
        statusinfo['currservice_end_timestamp'] = end_timestamp
        desc = curEvent[3]
        if six.PY2:
            desc = desc.decode('utf-8')
        if len(desc) > 220:
            desc = desc + u"..."
        if six.PY2:
            desc = desc.encode('utf-8')
        statusinfo['currservice_description'] = desc
        statusinfo['currservice_station'] = currservice_station
        if statusinfo['currservice_serviceref'].startswith('1:0:0'):
            statusinfo['currservice_filename'] = '/' + '/'.join(
                serviceref_string.split("/")[1:])
        full_desc = statusinfo['currservice_name'] + '\n'
        full_desc += statusinfo['currservice_begin'] + " - " + statusinfo[
            'currservice_end'] + '\n\n'
        full_desc += removeBad2(event.getExtendedDescription())
        statusinfo['currservice_fulldescription'] = full_desc
        statusinfo['currservice_id'] = curEvent[4]
    else:
        statusinfo['currservice_name'] = "N/A"
        statusinfo['currservice_begin'] = ""
        statusinfo['currservice_end'] = ""
        statusinfo['currservice_description'] = ""
        statusinfo['currservice_fulldescription'] = "N/A"
        if serviceref:
            statusinfo['currservice_serviceref'] = serviceref_string
            if statusinfo['currservice_serviceref'].startswith(
                    '1:0:0'
            ) or statusinfo['currservice_serviceref'].startswith('4097:0:0'):
                this_path = '/' + '/'.join(serviceref_string.split("/")[1:])
                if os.path.exists(this_path):
                    statusinfo['currservice_filename'] = this_path
            if serviceHandlerInfo:
                statusinfo['currservice_station'] = currservice_station
            elif serviceref_string.find("http") != -1:
                statusinfo['currservice_station'] = serviceref_string.replace(
                    '%3a', ':')[serviceref_string.find("http"):]
            else:
                statusinfo['currservice_station'] = "N/A"

    # Get Standby State
    from Screens.Standby import inStandby
    if inStandby is None:
        statusinfo['inStandby'] = "false"
    else:
        statusinfo['inStandby'] = "true"

    # Get recording state
    recs = NavigationInstance.instance.getRecordings()
    if recs:
        statusinfo['isRecording'] = "true"
        statusinfo['Recording_list'] = "\n"
        for timer in NavigationInstance.instance.RecordTimer.timer_list:
            if timer.state == TimerEntry.StateRunning:
                if not timer.justplay:
                    statusinfo['Recording_list'] += removeBad(
                        timer.service_ref.getServiceName(
                        )) + ": " + timer.name + "\n"
        if statusinfo['Recording_list'] == "\n":
            statusinfo['isRecording'] = "false"
    else:
        statusinfo['isRecording'] = "false"

    return statusinfo
Example #7
0
def getStreamServiceName(ref):
    if isinstance(ref, eServiceReference):
        servicereference = ServiceReference(ref)
        if servicereference:
            return removeBad(servicereference.getServiceName())
    return ""
Example #8
0
def getInfo(session=None, need_fullinfo=False):
    # TODO: get webif versione somewhere!
    info = {}
    global STATICBOXINFO

    if not (STATICBOXINFO is None or need_fullinfo):
        return STATICBOXINFO

    info['brand'] = getMachineBrand()
    info['model'] = getMachineName()
    info['boxtype'] = getBoxType()
    info['machinebuild'] = getMachineBuild()
    try:  # temporary due OE-A
        info['lcd'] = getLcd()
    except:  # noqa: E722
        info['lcd'] = 0
    try:  # temporary due OE-A
        info['grabpip'] = getGrabPip()
    except:  # noqa: E722
        info['grabpip'] = 0

    chipset = "unknown"
    if fileExists("/etc/.box"):
        f = open("/etc/.box", 'r')
        model = f.readline().strip().lower()
        f.close()
        if model.startswith("ufs") or model.startswith("ufc"):
            if model in ("ufs910", "ufs922", "ufc960"):
                chipset = "SH4 @266MHz"
            else:
                chipset = "SH4 @450MHz"
        elif model in ("topf", "tf7700hdpvr"):
            chipset = "SH4 @266MHz"
        elif model.startswith("azbox"):
            f = open("/proc/stb/info/model", 'r')
            model = f.readline().strip().lower()
            f.close()
            if model == "me":
                chipset = "SIGMA 8655"
            elif model == "minime":
                chipset = "SIGMA 8653"
            else:
                chipset = "SIGMA 8634"
        elif model.startswith("spark"):
            if model == "spark7162":
                chipset = "SH4 @540MHz"
            else:
                chipset = "SH4 @450MHz"
    elif fileExists("/proc/stb/info/azmodel"):
        f = open("/proc/stb/info/model", 'r')
        model = f.readline().strip().lower()
        f.close()
        if model == "me":
            chipset = "SIGMA 8655"
        elif model == "minime":
            chipset = "SIGMA 8653"
        else:
            chipset = "SIGMA 8634"
    elif fileExists("/proc/stb/info/model"):
        f = open("/proc/stb/info/model", 'r')
        model = f.readline().strip().lower()
        f.close()
        if model == "tf7700hdpvr":
            chipset = "SH4 @266MHz"
        elif model == "nbox":
            chipset = "STi7100 @266MHz"
        elif model == "arivalink200":
            chipset = "STi7109 @266MHz"
        elif model in ("adb2850", "adb2849", "dsi87"):
            chipset = "STi7111 @450MHz"
        elif model in ("sagemcom88", "esi88"):
            chipset = "STi7105 @450MHz"
        elif model.startswith("spark"):
            if model == "spark7162":
                chipset = "STi7162 @540MHz"
            else:
                chipset = "STi7111 @450MHz"
        elif model == "dm800":
            chipset = "bcm7401"
        elif model in ("dm800se", "dm500hd", "dm7020hd", "dm800sev2",
                       "dm500hdv2", "dm7020hdv2"):
            chipset = "bcm7405"
        elif model == "dm8000":
            chipset = "bcm7400"
        elif model in ("dm820", "dm7080"):
            chipset = "bcm7435"
        elif model in ("dm520", "dm525"):
            chipset = "bcm73625"
        elif model in ("dm900", "dm920"):
            chipset = "bcm7252S"

    if fileExists("/proc/stb/info/chipset"):
        f = open("/proc/stb/info/chipset", 'r')
        chipset = f.readline().strip()
        f.close()

    info['chipset'] = chipset

    memFree = 0
    for line in open("/proc/meminfo", 'r'):
        parts = line.split(':')
        key = parts[0].strip()
        if key == "MemTotal":
            info['mem1'] = parts[1].strip().replace("kB", _("kB"))
        elif key in ("MemFree", "Buffers", "Cached"):
            memFree += int(parts[1].strip().split(' ', 1)[0])
    info['mem2'] = "%s %s" % (memFree, _("kB"))
    info['mem3'] = _("%s free / %s total") % (info['mem2'], info['mem1'])

    try:
        f = open("/proc/uptime", "r")
        uptime = int(float(f.readline().split(' ', 2)[0].strip()))
        f.close()
        uptimetext = ''
        if uptime > 86400:
            d = uptime / 86400
            uptime = uptime % 86400
            uptimetext += '%dd ' % d
        uptimetext += "%d:%.2d" % (uptime / 3600, (uptime % 3600) / 60)
    except:  # noqa: E722
        uptimetext = "?"
    info['uptime'] = uptimetext

    info["webifver"] = OPENWEBIFVER
    info['imagedistro'] = getImageDistro()
    info['friendlyimagedistro'] = getFriendlyImageDistro()
    info['oever'] = getOEVersion()
    info['imagever'] = getImageVersion()
    ib = getImageBuild()
    if ib:
        info['imagever'] = info['imagever'] + "." + ib
    info['enigmaver'] = getEnigmaVersionString()
    info['driverdate'] = getDriverDate()
    info['kernelver'] = about.getKernelVersionString()

    try:
        from Tools.StbHardware import getFPVersion
    except ImportError:
        from Tools.DreamboxHardware import getFPVersion

    try:
        info['fp_version'] = getFPVersion()
    except:  # noqa: E722
        info['fp_version'] = None

    friendlychipsetdescription = _("Chipset")
    friendlychipsettext = info['chipset'].replace("bcm", "Broadcom ")
    if friendlychipsettext in ("7335", "7356", "7362", "73625", "7424", "7425",
                               "7429"):
        friendlychipsettext = "Broadcom " + friendlychipsettext
    if not (info['fp_version'] is None or info['fp_version'] == 0):
        friendlychipsetdescription = friendlychipsetdescription + " (" + _(
            "Front processor version") + ")"
        friendlychipsettext = friendlychipsettext + " (" + str(
            info['fp_version']) + ")"

    info['friendlychipsetdescription'] = friendlychipsetdescription
    info['friendlychipsettext'] = friendlychipsettext
    info['tuners'] = []
    for i in list(range(0, nimmanager.getSlotCount())):
        print(
            "[OpenWebif] -D- tuner '%d' '%s' '%s'" %
            (i, nimmanager.getNimName(i), nimmanager.getNim(i).getSlotName()))
        info['tuners'].append({
            "name":
            nimmanager.getNim(i).getSlotName(),
            "type":
            nimmanager.getNimName(i) + " (" +
            nimmanager.getNim(i).getFriendlyType() + ")",
            "rec":
            "",
            "live":
            ""
        })

    info['ifaces'] = []
    ifaces = iNetwork.getConfiguredAdapters()
    for iface in ifaces:
        info['ifaces'].append({
            "name":
            iNetwork.getAdapterName(iface),
            "friendlynic":
            getFriendlyNICChipSet(iface),
            "linkspeed":
            getLinkSpeed(iface),
            "mac":
            iNetwork.getAdapterAttribute(iface, "mac"),
            "dhcp":
            iNetwork.getAdapterAttribute(iface, "dhcp"),
            "ipv4method":
            getIPv4Method(iface),
            "ip":
            formatIp(iNetwork.getAdapterAttribute(iface, "ip")),
            "mask":
            formatIp(iNetwork.getAdapterAttribute(iface, "netmask")),
            "v4prefix":
            sum([
                bin(int(x)).count('1') for x in formatIp(
                    iNetwork.getAdapterAttribute(iface, "netmask")).split('.')
            ]),
            "gw":
            formatIp(iNetwork.getAdapterAttribute(iface, "gateway")),
            "ipv6":
            getAdapterIPv6(iface)['addr'],
            "ipmethod":
            getIPMethod(iface),
            "firstpublic":
            getAdapterIPv6(iface)['firstpublic']
        })

    info['hdd'] = []
    for hdd in harddiskmanager.hdd:
        dev = hdd.findMount()
        if dev:
            stat = os.statvfs(dev)
            free = stat.f_bavail * stat.f_frsize / 1048576.
        else:
            free = -1

        if free <= 1024:
            free = "%i %s" % (free, _("MB"))
        else:
            free = free / 1024.
            free = "%.1f %s" % (free, _("GB"))

        size = hdd.diskSize() * 1000000 / 1048576.
        if size > 1048576:
            size = "%.1f %s" % ((size / 1048576.), _("TB"))
        elif size > 1024:
            size = "%.1f %s" % ((size / 1024.), _("GB"))
        else:
            size = "%d %s" % (size, _("MB"))

        iecsize = hdd.diskSize()
        # Harddisks > 1000 decimal Gigabytes are labelled in TB
        if iecsize > 1000000:
            iecsize = (iecsize + 50000) // float(100000) / 10
            # Omit decimal fraction if it is 0
            if (iecsize % 1 > 0):
                iecsize = "%.1f %s" % (iecsize, _("TB"))
            else:
                iecsize = "%d %s" % (iecsize, _("TB"))
        # Round harddisk sizes beyond ~300GB to full tens: 320, 500, 640, 750GB
        elif iecsize > 300000:
            iecsize = "%d %s" % (((iecsize + 5000) // 10000 * 10), _("GB"))
        # ... be more precise for media < ~300GB (Sticks, SSDs, CF, MMC, ...): 1, 2, 4, 8, 16 ... 256GB
        elif iecsize > 1000:
            iecsize = "%d %s" % (((iecsize + 500) // 1000), _("GB"))
        else:
            iecsize = "%d %s" % (iecsize, _("MB"))

        info['hdd'].append({
            "model":
            hdd.model(),
            "capacity":
            size,
            "labelled_capacity":
            iecsize,
            "free":
            free,
            "mount":
            dev,
            "friendlycapacity":
            _("%s free / %s total") % (free, size + ' ("' + iecsize + '")')
        })

    info['shares'] = []
    autofiles = ('/etc/auto.network', '/etc/auto.network_vti')
    for autofs in autofiles:
        if fileExists(autofs):
            method = "autofs"
            for line in open(autofs).readlines():
                if not line.startswith('#'):
                    # Replace escaped spaces that can appear inside credentials with underscores
                    # Not elegant but we wouldn't want to expose credentials on the OWIF anyways
                    tmpline = line.replace("\ ", "_")
                    tmp = tmpline.split()
                    if not len(tmp) == 3:
                        continue
                    name = tmp[0].strip()
                    type = "unknown"
                    if "cifs" in tmp[1]:
                        # Linux still defaults to SMBv1
                        type = "SMBv1.0"
                        settings = tmp[1].split(",")
                        for setting in settings:
                            if setting.startswith("vers="):
                                type = setting.replace("vers=", "SMBv")
                    elif "nfs" in tmp[1]:
                        type = "NFS"

                    # Default is r/w
                    mode = _("r/w")
                    settings = tmp[1].split(",")
                    for setting in settings:
                        if setting == "ro":
                            mode = _("r/o")

                    uri = tmp[2]
                    parts = []
                    parts = tmp[2].split(':')
                    if parts[0] == "":
                        server = uri.split('/')[2]
                        uri = uri.strip()[1:]
                    else:
                        server = parts[0]

                    ipaddress = None
                    if server:
                        # Will fail on literal IPs
                        try:
                            # Try IPv6 first, as will Linux
                            if has_ipv6:
                                tmpaddress = None
                                tmpaddress = getaddrinfo(server, 0, AF_INET6)
                                if tmpaddress:
                                    ipaddress = "[" + list(
                                        tmpaddress)[0][4][0] + "]"
                            # Use IPv4 if IPv6 fails or is not present
                            if ipaddress is None:
                                tmpaddress = None
                                tmpaddress = getaddrinfo(server, 0, AF_INET)
                                if tmpaddress:
                                    ipaddress = list(tmpaddress)[0][4][0]
                        except:  # noqa: E722
                            pass

                    friendlyaddress = server
                    if ipaddress is not None and not ipaddress == server:
                        friendlyaddress = server + " (" + ipaddress + ")"
                    info['shares'].append({
                        "name": name,
                        "method": method,
                        "type": type,
                        "mode": mode,
                        "path": uri,
                        "host": server,
                        "ipaddress": ipaddress,
                        "friendlyaddress": friendlyaddress
                    })
    # TODO: fstab

    info['transcoding'] = TRANSCODING

    info['EX'] = ''

    if session:
        try:
            #  gets all current stream clients for images using eStreamServer
            #  TODO: merge eStreamServer and streamList
            #  TODO: get tuner info for streams
            #  TODO: get recoding/timer info if more than one
            info['streams'] = []
            try:
                from enigma import eStreamServer
                streamServer = eStreamServer.getInstance()
                if streamServer is not None:
                    for x in streamServer.getConnectedClients():
                        servicename = ServiceReference(
                            x[1]).getServiceName() or "(unknown service)"
                        if int(x[2]) == 0:
                            strtype = "S"
                        else:
                            strtype = "T"
                        info['streams'].append({
                            "ref": x[1],
                            "name": servicename,
                            "ip": x[0],
                            "type": strtype
                        })
            except Exception as error:
                print("[OpenWebif] -D- no eStreamServer %s" % error)

            recs = NavigationInstance.instance.getRecordings()
            if recs:
                #  only one stream and only TV
                from Plugins.Extensions.OpenWebif.controllers.stream import streamList
                s_name = ''
                #  s_cip = ''

                print("[OpenWebif] -D- streamList count '%d'" %
                      len(streamList))
                if len(streamList) == 1:
                    from Screens.ChannelSelection import service_types_tv
                    # from enigma import eEPGCache
                    # epgcache = eEPGCache.getInstance()
                    serviceHandler = eServiceCenter.getInstance()
                    services = serviceHandler.list(
                        eServiceReference('%s ORDER BY name' %
                                          (service_types_tv)))
                    channels = services and services.getContent("SN", True)
                    s = streamList[0]
                    srefs = s.ref.toString()
                    for channel in channels:
                        if srefs == channel[0]:
                            s_name = channel[1] + ' (' + s.clientIP + ')'
                            break
                print("[OpenWebif] -D- s_name '%s'" % s_name)

                # only for debug
                for stream in streamList:
                    srefs = stream.ref.toString()
                    print("[OpenWebif] -D- srefs '%s'" % srefs)

                sname = ''
                timers = []
                for timer in NavigationInstance.instance.RecordTimer.timer_list:
                    if timer.isRunning() and not timer.justplay:
                        timers.append(
                            removeBad(timer.service_ref.getServiceName()))
                        print("[OpenWebif] -D- timer '%s'" %
                              timer.service_ref.getServiceName())


# TODO: more than one recording
                if len(timers) == 1:
                    sname = timers[0]

                if sname == '' and s_name != '':
                    sname = s_name

                print("[OpenWebif] -D- recs count '%d'" % len(recs))

                for rec in recs:
                    feinfo = rec.frontendInfo()
                    frontendData = feinfo and feinfo.getAll(True)
                    if frontendData is not None:
                        cur_info = feinfo.getTransponderData(True)
                        if cur_info:
                            nr = frontendData['tuner_number']
                            info['tuners'][nr]['rec'] = getOrbitalText(
                                cur_info) + ' / ' + sname

            service = session.nav.getCurrentService()
            if service is not None:
                sname = service.info().getName()
                feinfo = service.frontendInfo()
                frontendData = feinfo and feinfo.getAll(True)
                if frontendData is not None:
                    cur_info = feinfo.getTransponderData(True)
                    if cur_info:
                        nr = frontendData['tuner_number']
                        info['tuners'][nr]['live'] = getOrbitalText(
                            cur_info) + ' / ' + sname
        except Exception as error:
            info['EX'] = error

    info['timerpipzap'] = False
    info['timerautoadjust'] = False

    try:
        timer = RecordTimerEntry(ServiceReference("1:0:1:0:0:0:0:0:0:0"), 0, 0,
                                 '', '', 0)
        if hasattr(timer, "pipzap"):
            info['timerpipzap'] = True
        if hasattr(timer, "autoadjust"):
            info['timerautoadjust'] = True
    except Exception as error:
        print("[OpenWebif] -D- RecordTimerEntry check %s" % error)

    STATICBOXINFO = info
    return info
Example #9
0
def getInfo(session=None, need_fullinfo=False):
    # TODO: get webif versione somewhere!
    info = {}
    global STATICBOXINFO

    if not (STATICBOXINFO is None or need_fullinfo):
        return STATICBOXINFO

    info['brand'] = getBoxBrand()
    info['model'] = getBoxType()
    info['platform'] = boxbranding.getMachineBuild()

    try:
        info['procmodel'] = getBoxProc()
    except:  # noqa: E722
        info['procmodel'] = boxbranding.getMachineProcModel()

    try:
        info['procmodeltype'] = getBoxProcType()
    except:  # noqa: E722
        info['procmodeltype'] = None

    try:
        info['lcd'] = getLcd()
    except:  # noqa: E722
        info['lcd'] = 0

    try:
        info['grabpip'] = getGrabPip()
    except:  # noqa: E722
        info['grabpip'] = 0

    cpu = about.getCPUInfoString()
    info['chipset'] = cpu
    info['cpubrand'] = about.getCPUBrand()
    info['socfamily'] = boxbranding.getSoCFamily()
    info['cpuarch'] = about.getCPUArch()
    if config.OpenWebif.about_benchmark.value is True:
        info['cpubenchmark'] = about.getCPUBenchmark()
    else:
        info['cpubenchmark'] = _("Disabled in configuration")
    info['flashtype'] = about.getFlashType()

    memFree = 0
    for line in open("/proc/meminfo", 'r'):
        parts = line.split(':')
        key = parts[0].strip()
        if key == "MemTotal":
            info['mem1'] = parts[1].strip().replace("kB", _("kB"))
        elif key in ("MemFree", "Buffers", "Cached"):
            memFree += int(parts[1].strip().split(' ', 1)[0])
    info['mem2'] = "%s %s" % (memFree, _("kB"))
    info['mem3'] = _("%s free / %s total") % (info['mem2'], info['mem1'])

    info['uptime'] = about.getBoxUptime()

    info["webifver"] = OPENWEBIFVER
    info['imagedistro'] = boxbranding.getImageDistro()
    info['oever'] = boxbranding.getImageBuild()
    info['visionversion'] = boxbranding.getVisionVersion()
    info['visionrevision'] = boxbranding.getVisionRevision()
    info['visionmodule'] = about.getVisionModule()

    if fileExists("/etc/openvision/multiboot"):
        multibootflag = open("/etc/openvision/multiboot", "r").read().strip()
        if multibootflag == "1":
            info['multiboot'] = _("Yes")
        else:
            info['multiboot'] = _("No")
    else:
        info['multiboot'] = _("Yes")

    info['enigmaver'] = getEnigmaVersionString()
    info['driverdate'] = about.getDriverInstalledDate()
    info['kernelver'] = boxbranding.getKernelVersion()
    info['dvbapitype'] = about.getDVBAPI()
    info['gstreamerversion'] = about.getGStreamerVersionString(cpu)
    info['ffmpegversion'] = about.getFFmpegVersionString()
    info['pythonversion'] = about.getPythonVersionString()

    try:
        info['hwserial'] = getHWSerial()
    except:  # noqa: E722
        info['hwserial'] = None

    if (info['hwserial'] is None or info['hwserial'] == "unknown"):
        info['hwserial'] = about.getCPUSerial()

    try:
        info['boxrctype'] = getBoxRCType()
    except:  # noqa: E722
        info['boxrctype'] = None

    if (info['boxrctype'] is None or info['boxrctype'] == "unknown"):
        if fileExists("/usr/bin/remotecfg"):
            info['boxrctype'] = _("Amlogic remote")
        elif fileExists("/usr/sbin/lircd"):
            info['boxrctype'] = _("LIRC remote")

    info['ovrctype'] = boxbranding.getRCType()
    info['ovrcname'] = boxbranding.getRCName()
    info['ovrcidnum'] = boxbranding.getRCIDNum()

    info['transcoding'] = boxbranding.getHaveTranscoding()
    info['multitranscoding'] = boxbranding.getHaveMultiTranscoding()

    info['displaytype'] = boxbranding.getDisplayType()

    info['updatedatestring'] = about.getUpdateDateString()
    info['enigmadebuglvl'] = eGetEnigmaDebugLvl()

    info['imagearch'] = boxbranding.getImageArch()
    info['imagefolder'] = boxbranding.getImageFolder()
    info['imagefilesystem'] = boxbranding.getImageFileSystem()
    info['feedsurl'] = boxbranding.getFeedsUrl()
    info['developername'] = boxbranding.getDeveloperName()
    info['builddatestring'] = about.getBuildDateString()
    info['imagefpu'] = boxbranding.getImageFPU()
    info['havemultilib'] = boxbranding.getHaveMultiLib()

    try:
        info['fp_version'] = getFPVersion()
    except:  # noqa: E722
        info['fp_version'] = None

    info['tuners'] = []
    for i in list(range(0, nimmanager.getSlotCount())):
        print(
            "[OpenWebif] -D- tuner '%d' '%s' '%s'" %
            (i, nimmanager.getNimName(i), nimmanager.getNim(i).getSlotName()))
        info['tuners'].append({
            "name":
            nimmanager.getNim(i).getSlotName(),
            "type":
            nimmanager.getNimName(i) + " (" +
            nimmanager.getNim(i).getFriendlyType() + ")",
            "rec":
            "",
            "live":
            ""
        })

    info['ifaces'] = []
    ifaces = iNetwork.getConfiguredAdapters()
    for iface in ifaces:
        info['ifaces'].append({
            "name":
            iNetwork.getAdapterName(iface),
            "friendlynic":
            getFriendlyNICChipSet(iface),
            "linkspeed":
            getLinkSpeed(iface),
            "mac":
            iNetwork.getAdapterAttribute(iface, "mac"),
            "dhcp":
            iNetwork.getAdapterAttribute(iface, "dhcp"),
            "ipv4method":
            getIPv4Method(iface),
            "ip":
            formatIp(iNetwork.getAdapterAttribute(iface, "ip")),
            "mask":
            formatIp(iNetwork.getAdapterAttribute(iface, "netmask")),
            "v4prefix":
            sum([
                bin(int(x)).count('1') for x in formatIp(
                    iNetwork.getAdapterAttribute(iface, "netmask")).split('.')
            ]),
            "gw":
            formatIp(iNetwork.getAdapterAttribute(iface, "gateway")),
            "ipv6":
            getAdapterIPv6(iface)['addr'],
            "ipmethod":
            getIPMethod(iface),
            "firstpublic":
            getAdapterIPv6(iface)['firstpublic']
        })

    info['hdd'] = []
    for hdd in harddiskmanager.hdd:
        dev = hdd.findMount()
        if dev:
            stat = os.statvfs(dev)
            free = stat.f_bavail * stat.f_frsize / 1048576.
        else:
            free = -1

        if free <= 1024:
            free = "%i %s" % (free, _("MB"))
        else:
            free = free / 1024.
            free = "%.1f %s" % (free, _("GB"))

        size = hdd.diskSize() * 1000000 / 1048576.
        if size > 1048576:
            size = "%.1f %s" % ((size / 1048576.), _("TB"))
        elif size > 1024:
            size = "%.1f %s" % ((size / 1024.), _("GB"))
        else:
            size = "%d %s" % (size, _("MB"))

        iecsize = hdd.diskSize()
        # Harddisks > 1000 decimal Gigabytes are labelled in TB
        if iecsize > 1000000:
            iecsize = (iecsize + 50000) // float(100000) / 10
            # Omit decimal fraction if it is 0
            if (iecsize % 1 > 0):
                iecsize = "%.1f %s" % (iecsize, _("TB"))
            else:
                iecsize = "%d %s" % (iecsize, _("TB"))
        # Round harddisk sizes beyond ~300GB to full tens: 320, 500, 640, 750GB
        elif iecsize > 300000:
            iecsize = "%d %s" % (((iecsize + 5000) // 10000 * 10), _("GB"))
        # ... be more precise for media < ~300GB (Sticks, SSDs, CF, MMC, ...): 1, 2, 4, 8, 16 ... 256GB
        elif iecsize > 1000:
            iecsize = "%d %s" % (((iecsize + 500) // 1000), _("GB"))
        else:
            iecsize = "%d %s" % (iecsize, _("MB"))

        info['hdd'].append({
            "model":
            hdd.model(),
            "capacity":
            size,
            "labelled_capacity":
            iecsize,
            "free":
            free,
            "mount":
            dev,
            "friendlycapacity":
            _("%s free / %s total") % (free, size + ' ("' + iecsize + '")')
        })

    info['shares'] = []
    autofiles = ('/etc/auto.network', '/etc/auto.network_vti')
    for autofs in autofiles:
        if fileExists(autofs):
            method = "autofs"
            for line in open(autofs).readlines():
                if not line.startswith('#'):
                    # Replace escaped spaces that can appear inside credentials with underscores
                    # Not elegant but we wouldn't want to expose credentials on the OWIF anyways
                    tmpline = line.replace("\ ", "_")
                    tmp = tmpline.split()
                    if not len(tmp) == 3:
                        continue
                    name = tmp[0].strip()
                    type = "unknown"
                    if "cifs" in tmp[1]:
                        # Linux still defaults to SMBv1
                        type = "SMBv1.0"
                        settings = tmp[1].split(",")
                        for setting in settings:
                            if setting.startswith("vers="):
                                type = setting.replace("vers=", "SMBv")
                    elif "nfs" in tmp[1]:
                        type = "NFS"

                    # Default is r/w
                    mode = _("r/w")
                    settings = tmp[1].split(",")
                    for setting in settings:
                        if setting == "ro":
                            mode = _("r/o")

                    uri = tmp[2]
                    parts = []
                    parts = tmp[2].split(':')
                    if parts[0] == "":
                        server = uri.split('/')[2]
                        uri = uri.strip()[1:]
                    else:
                        server = parts[0]

                    ipaddress = None
                    if server:
                        # Will fail on literal IPs
                        try:
                            # Try IPv6 first, as will Linux
                            if has_ipv6:
                                tmpaddress = None
                                tmpaddress = getaddrinfo(server, 0, AF_INET6)
                                if tmpaddress:
                                    ipaddress = "[" + list(
                                        tmpaddress)[0][4][0] + "]"
                            # Use IPv4 if IPv6 fails or is not present
                            if ipaddress is None:
                                tmpaddress = None
                                tmpaddress = getaddrinfo(server, 0, AF_INET)
                                if tmpaddress:
                                    ipaddress = list(tmpaddress)[0][4][0]
                        except:  # noqa: E722
                            pass

                    friendlyaddress = server
                    if ipaddress is not None and not ipaddress == server:
                        friendlyaddress = server + " (" + ipaddress + ")"
                    info['shares'].append({
                        "name": name,
                        "method": method,
                        "type": type,
                        "mode": mode,
                        "path": uri,
                        "host": server,
                        "ipaddress": ipaddress,
                        "friendlyaddress": friendlyaddress
                    })
    # TODO: fstab

    info['EX'] = ''

    if session:
        try:
            #  gets all current stream clients for images using eStreamServer
            #  TODO: merge eStreamServer and streamList
            #  TODO: get tuner info for streams
            #  TODO: get recoding/timer info if more than one
            info['streams'] = []
            try:
                from enigma import eStreamServer
                streamServer = eStreamServer.getInstance()
                if streamServer is not None:
                    for x in streamServer.getConnectedClients():
                        servicename = ServiceReference(
                            x[1]).getServiceName() or "(unknown service)"
                        if int(x[2]) == 0:
                            strtype = "S"
                        else:
                            strtype = "T"
                        info['streams'].append({
                            "ref": x[1],
                            "name": servicename,
                            "ip": x[0],
                            "type": strtype
                        })
            except Exception as error:
                print("[OpenWebif] -D- no eStreamServer %s" % error)
            recs = NavigationInstance.instance.getRecordings()
            if recs:
                #  only one stream and only TV
                from Plugins.Extensions.OpenWebif.controllers.stream import streamList
                s_name = ''
                # s_cip = ''

                print("[OpenWebif] -D- streamList count '%d'" %
                      len(streamList))
                if len(streamList) == 1:
                    from Screens.ChannelSelection import service_types_tv
                    # from enigma import eEPGCache
                    # epgcache = eEPGCache.getInstance()
                    serviceHandler = eServiceCenter.getInstance()
                    services = serviceHandler.list(
                        eServiceReference('%s ORDER BY name' %
                                          (service_types_tv)))
                    channels = services and services.getContent("SN", True)
                    s = streamList[0]
                    srefs = s.ref.toString()
                    for channel in channels:
                        if srefs == channel[0]:
                            s_name = channel[1] + ' (' + s.clientIP + ')'
                            break
                print("[OpenWebif] -D- s_name '%s'" % s_name)

                # only for debug
                for stream in streamList:
                    srefs = stream.ref.toString()
                    print("[OpenWebif] -D- srefs '%s'" % srefs)

                sname = ''
                timers = []
                for timer in NavigationInstance.instance.RecordTimer.timer_list:
                    if timer.isRunning() and not timer.justplay:
                        timers.append(
                            removeBad(timer.service_ref.getServiceName()))
                        print("[OpenWebif] -D- timer '%s'" %
                              timer.service_ref.getServiceName())


# TODO: more than one recording
                if len(timers) == 1:
                    sname = timers[0]

                if sname == '' and s_name != '':
                    sname = s_name

                print("[OpenWebif] -D- recs count '%d'" % len(recs))

                for rec in recs:
                    feinfo = rec.frontendInfo()
                    frontendData = feinfo and feinfo.getAll(True)
                    if frontendData is not None:
                        cur_info = feinfo.getTransponderData(True)
                        if cur_info:
                            nr = frontendData['tuner_number']
                            info['tuners'][nr]['rec'] = getOrbitalText(
                                cur_info) + ' / ' + sname

            service = session.nav.getCurrentService()
            if service is not None:
                sname = service.info().getName()
                feinfo = service.frontendInfo()
                frontendData = feinfo and feinfo.getAll(True)
                if frontendData is not None:
                    cur_info = feinfo.getTransponderData(True)
                    if cur_info:
                        nr = frontendData['tuner_number']
                        info['tuners'][nr]['live'] = getOrbitalText(
                            cur_info) + ' / ' + sname
        except Exception as error:
            info['EX'] = error

    info['timerpipzap'] = False
    info['timerautoadjust'] = False

    try:
        timer = RecordTimerEntry('', 0, 0, '', '', 0)
        if hasattr(timer, "pipzap"):
            info['timerpipzap'] = True
        if hasattr(timer, "autoadjust"):
            info['timerautoadjust'] = True
    except Exception as error:
        print("[OpenWebif] -D- RecordTimerEntry check %s" % error)

    STATICBOXINFO = info
    return info
Example #10
0
def getTimers(session):
	rt = session.nav.RecordTimer
	timers = []
	for timer in rt.timer_list + rt.processed_timers:
		if hasattr(timer, "wakeup_t"):
			energytimer = timer.wakeup_t or timer.standby_t or timer.shutdown_t or timer.fnc_t != "off" or 0
			if energytimer:
				continue

		descriptionextended = "N/A"
		filename = None
		nextactivation = None
		if timer.eit and timer.service_ref:
			event = eEPGCache.getInstance().lookupEvent(['EX', (str(timer.service_ref), 2, timer.eit)])
			if event and event[0][0]:
				descriptionextended = event[0][0]

		try:
			filename = timer.Filename
		except Exception:
			pass

		try:
			nextactivation = timer.next_activation
		except Exception:
			pass

		disabled = 0
		if timer.disabled:
			disabled = 1

		justplay = 0
		if timer.justplay:
			justplay = 1

		if hasattr(timer, "allow_duplicate"):
			allow_duplicate = timer.allow_duplicate and 1 or 0
		else:
			allow_duplicate = 1

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

		if timer.dirname:
			dirname = timer.dirname
		else:
			dirname = "None"

		dontSave = 0
		if timer.dontSave:
			dontSave = 1

		toggledisabled = 1
		if timer.disabled:
				toggledisabled = 0

		toggledisabledimg = "off"
		if timer.disabled:
				toggledisabledimg = "on"

		asrefs = ""
		achannels = GetWithAlternative(str(timer.service_ref), False)
		if achannels:
			asrefs = achannels

		vpsplugin_enabled = False
		vpsplugin_overwrite = False
		vpsplugin_time = -1
		if hasattr(timer, "vpsplugin_enabled"):
			vpsplugin_enabled = True if timer.vpsplugin_enabled else False
		if hasattr(timer, "vpsplugin_overwrite"):
			vpsplugin_overwrite = True if timer.vpsplugin_overwrite else False
		if hasattr(timer, "vpsplugin_time"):
			vpsplugin_time = timer.vpsplugin_time
			if not vpsplugin_time:
				vpsplugin_time = -1

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

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

		isAutoTimer = -1
		if hasattr(timer, "isAutoTimer"):
			if timer.isAutoTimer:
				isAutoTimer = 1
			else:
				isAutoTimer = 0

		if six.PY2:
			descriptionextended = six.text_type(descriptionextended, 'utf_8', errors='ignore').encode('utf_8', 'ignore')

		timers.append({
			"serviceref": str(timer.service_ref),
			"servicename": removeBad(timer.service_ref.getServiceName()),
			"eit": timer.eit,
			"name": timer.name,
			"description": timer.description,
			"descriptionextended": descriptionextended,
			"disabled": disabled,
			"begin": timer.begin,
			"end": timer.end,
			"duration": timer.end - timer.begin,
			"startprepare": timer.start_prepare,
			"justplay": justplay,
			"afterevent": timer.afterEvent,
			"dirname": dirname,
			"tags": " ".join(timer.tags),
			"logentries": timer.log_entries,
			"backoff": timer.backoff,
			"firsttryprepare": timer.first_try_prepare,
			"state": timer.state,
			"repeated": timer.repeated,
			"dontsave": dontSave,
			"cancelled": timer.cancelled,
			"toggledisabled": toggledisabled,
			"toggledisabledimg": toggledisabledimg,
			"filename": filename,
			"nextactivation": nextactivation,
			"realbegin": strftime("%d.%m.%Y %H:%M", (localtime(float(timer.begin)))),
			"realend": strftime("%d.%m.%Y %H:%M", (localtime(float(timer.end)))),
			"asrefs": asrefs,
			"vpsplugin_enabled": vpsplugin_enabled,
			"vpsplugin_overwrite": vpsplugin_overwrite,
			"vpsplugin_time": vpsplugin_time,
			"always_zap": always_zap,
			"pipzap": pipzap,
			"isAutoTimer": isAutoTimer,
			"allow_duplicate": allow_duplicate,
			"autoadjust": autoadjust
		})

	return {
		"result": True,
		"timers": timers
	}