예제 #1
0
    def __init__(self, *args):
        XBMCMonitor.__init__(self)
        self.getSettings()
        handler.notifyLog('Init Service %s %s' % (__addonname__, __version__))

        self.timers = handler.getTimer()
        handler.setTimerProperties(self.timers)
예제 #2
0
    def switchToChannelId(cls, playerProperties, channelId, channel):

        if playerProperties['player'] == 'audio' or (playerProperties['player'] == 'video' and playerProperties['media'] != 'channel'):

            # stop all other players except pvr

            handler.notifyLog('player:%s media:%s @id:%s is running' %
                              (playerProperties['player'], playerProperties['media'], playerProperties['playerid']))
            query = {
                "method": "Player.Stop",
                "params": {"playerid": playerProperties['playerid']},
            }
            res = jsonrpc(query)
            if 'result' in res and res['result'] == "OK":
                handler.notifyLog('Player stopped')

        handler.notifyLog('Currently playing channelid %s, switch to id %s' % (playerProperties['id'], channelId))
        query = {
            "method": "Player.Open",
            "params": {"item": {"channelid": channelId}}
        }
        res = jsonrpc(query)
        if 'result' in res and res['result'] == 'OK':
            handler.notifyLog('Switched to channel \'%s\'' % (channel))
        else:
            handler.notifyLog('Couldn\'t switch to channel \'%s\'' % (channel))
            handler.notifyOSD(loc(30000), loc(30025) % (channel), icon=IconAlert)
예제 #3
0
    def getSettings(self):
        self.__showNoticeBeforeSw = True if __addon__.getSetting('showNoticeBeforeSw').upper() == 'TRUE' else False
        self.__dispMsgTime = int(re.match('\d+', __addon__.getSetting('dispTime')).group())*1000
        self.__discardTmr = int(re.match('\d+', __addon__.getSetting('discardOldTmr')).group())*60
        self.__confirmTmrAdded = True if __addon__.getSetting('confirmTmrAdded').upper() == 'TRUE' else False
        self.__dateFormat = handler.getDateFormat()

        handler.notifyLog('Settings (re)loaded')
        self.SettingsChanged = False
예제 #4
0
    def __init__(self, *args):

        knClasses.XBMCMonitor.__init__(self)
        self.skinPath = None

        self.getSettings()
        handler.notifyLog('Init Service %s %s' % (addonname, version))
        self.bootstrap = True
        self.timers = handler.getTimer()
        handler.setTimerProperties(self.timers)
    def getSettings(self):
        self.__showNoticeBeforeSw = True if __addon__.getSetting("showNoticeBeforeSw").upper() == "TRUE" else False
        self.__useCountdownTimer = True if __addon__.getSetting("useCountdownTimer").upper() == "TRUE" else False
        self.__dispMsgTime = int(re.match("\d+", __addon__.getSetting("dispTime")).group()) * 1000
        self.__discardTmr = int(re.match("\d+", __addon__.getSetting("discardOldTmr")).group()) * 60
        self.__confirmTmrAdded = True if __addon__.getSetting("confirmTmrAdded").upper() == "TRUE" else False
        self.__dateFormat = handler.getDateFormat()

        handler.notifyLog("Settings (re)loaded")
        self.SettingsChanged = False
예제 #6
0
파일: deltimer.py 프로젝트: smplgd/repo
#!/usr/bin/python
# -*- coding: utf-8 -*-

import handler

if __name__ ==  '__main__':

    handler.notifyLog('Parameter handler called: delete timerlist')
    handler.clearTimerProperties()
예제 #7
0
파일: deltimer.py 프로젝트: PetteriLah/repo
import xbmc
import handler

if __name__ == '__main__':

    handler.notifyLog('Parameter handler called: Delete Timerlist')
    try:
        if not handler.clearTimerList():
            handler.notifyLog('Timerlist couldn\'t deleted', xbmc.LOGERROR)
    except Exception, e:
        handler.notifyLog('Script error, Timer couldn\'t deleted',
                          xbmc.LOGERROR)
예제 #8
0
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL):
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            _switchInstantly = False

            for _timer in self.timers:

                if not _timer['utime']:
                    handler.notifyLog(
                        'Couldn\'t calculate timestamp, delete timer',
                        xbmc.LOGERROR)
                    self.resetTmr(_timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetTmr(_timer['date'])
                    continue

                if _timer['utime'] < _now: _switchInstantly = True
                if (_timer['utime'] - _now < INTERVAL +
                        self.__dispMsgTime / 1000) or _switchInstantly:
                    chanIdTmr = self.channelName2channelId(
                        _timer['channel'].decode('utf-8'))
                    if chanIdTmr:

                        # get player properties, switch if necessary

                        plrProps = self.getPlayer()
                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30027) %
                                (_timer['channel'].decode('utf-8')),
                                time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog(
                                'Channel switch to %s required' %
                                (_timer['channel'].decode('utf-8')))

                            if _switchInstantly:
                                handler.notifyLog(
                                    'immediate channel switching required')
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30027) %
                                    (_timer['channel'].decode('utf-8')),
                                    time=5000)

                            elif not self.__showNoticeBeforeSw:
                                xbmc.sleep(self.__dispMsgTime)

                            elif self.__useCountdownTimer:
                                handler.OSDProgress.create(
                                    __LS__(30028),
                                    __LS__(30026) %
                                    (_timer['title'], _timer['channel']),
                                    __LS__(30029) %
                                    (int(self.__dispMsgTime / 1000 - secs)))
                                while secs < self.__dispMsgTime / 1000:
                                    secs += 1
                                    percent = int(
                                        (secs * 100000) / self.__dispMsgTime)
                                    handler.OSDProgress.update(
                                        percent,
                                        __LS__(30026) %
                                        (_timer['title'], _timer['channel']),
                                        __LS__(30029) %
                                        (int(self.__dispMsgTime / 1000 -
                                             secs)))
                                    xbmc.sleep(1000)
                                    if (handler.OSDProgress.iscanceled()):
                                        switchAborted = True
                                        break
                                handler.OSDProgress.close()
                            else:
                                idleTime = xbmc.getGlobalIdleTime()
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30026) %
                                    (_timer['title'].decode('utf-8'),
                                     _timer['channel'].decode('utf-8')),
                                    time=self.__dispMsgTime)
                                while secs < self.__dispMsgTime / 1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break
                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    secs += 1
                                if switchAborted:
                                    handler.notifyOSD(__LS__(30000),
                                                      __LS__(30032))

                            if switchAborted:
                                handler.notifyLog(
                                    'Channelswitch cancelled by user')
                            else:
                                if plrProps['player'] == 'audio' or (
                                        plrProps['player'] == 'video'
                                        and plrProps['media'] != 'channel'):

                                    # stop all other players except pvr

                                    handler.notifyLog(
                                        'player:%s media:%s @id:%s is running'
                                        %
                                        (plrProps['player'], plrProps['media'],
                                         plrProps['playerid']))
                                    query = {
                                        "method": "Player.Stop",
                                        "params": {
                                            "playerid": plrProps['playerid']
                                        },
                                    }
                                    res = jsonrpc(query)
                                    if 'result' in res and res[
                                            'result'] == "OK":
                                        handler.notifyLog('Player stopped')

                                handler.notifyLog(
                                    'Currently playing channelid %s, switch to id %s'
                                    % (plrProps['id'], chanIdTmr))
                                query = {
                                    "method": "Player.Open",
                                    "params": {
                                        "item": {
                                            "channelid": chanIdTmr
                                        }
                                    }
                                }
                                res = jsonrpc(query)
                                if 'result' in res and res['result'] == 'OK':
                                    handler.notifyLog(
                                        'Switched to channel \'%s\'' %
                                        (_timer['channel'].decode('utf-8')))
                                else:
                                    handler.notifyLog(
                                        'Couldn\'t switch to channel \'%s\'' %
                                        (_timer['channel'].decode('utf-8')))
                                    handler.notifyOSD(
                                        __LS__(30000),
                                        __LS__(30025) %
                                        (_timer['channel'].decode('utf-8')),
                                        icon=__IconAlert__)

                    self.resetTmr(_timer['date'])
            self.timers = handler.getTimer()

        handler.notifyLog('Service kicks off')
예제 #9
0
파일: service.py 프로젝트: PetteriLah/repo
 def __init__(self, *args):
     XBMCMonitor.__init__(self)
     self.__dateFormat = None
     self.activeTimers = 0
     self.getSettings()
     handler.notifyLog('Init Service %s %s' % (__addonname__, __version__))
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL):
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            timers = handler.readTimerStrings()
            for _timer in timers:

                if not _timer["utime"]:
                    handler.notifyLog("Couldn't calculate timestamp, delete timer", xbmc.LOGERROR)
                    self.resetSwitchTimer(_timer["channel"], _timer["date"])
                    break

                # delete old/discarded timers
                if _timer["utime"] + self.__discardTmr < _now:
                    self.resetSwitchTimer(_timer["channel"], _timer["date"])
                    continue

                _timediff = INTERVAL + self.__dispMsgTime / 1000
                if _timer["utime"] - _now < _timediff:
                    chanIdTmr = self.channelName2channelId(_timer["channel"].decode("utf-8"))
                    if chanIdTmr:

                        # get player properties, switch if necessary

                        plrProps = self.getPlayer()
                        if chanIdTmr == plrProps["id"]:
                            handler.notifyLog("Channel switching not required")
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30027) % (_timer["channel"].decode("utf-8")),
                                time=self.__dispMsgTime,
                            )
                        else:
                            idleTime = xbmc.getGlobalIdleTime()
                            countdown = 0
                            switchAborted = False

                            handler.notifyLog("Channel switch to " + _timer["channel"].decode("utf-8") + "required")

                            if self.__useCountdownTimer:

                                # TODO:
                                # - only check every 30s, this should be enough, see line 24
                                # - the switch dialog should appear @ starttime minus 30s minus dialog-displaytime
                                #   then the user has enough time to react
                                # - translate "Switch to channel" and "seconds left". I'm too lazy right now ;)

                                ret = msgdialogprogress.create(
                                    "Channel switch requested",
                                    "Switch to Channel:" + (_timer["channel"].decode("utf-8")),
                                )
                                secs = 0
                                percent = 0
                                time_to_wait = self.__dispMsgTime
                                # use the multiplier 100 to get better %/calculation
                                increment = 100 * 100 / time_to_wait
                                cancelled = False
                                while secs < time_to_wait:
                                    secs = secs + 1
                                    # divide with 100, to get the right value
                                    percent = increment * secs / 100
                                    secs_left = str((time_to_wait - secs))
                                    remaining_display = str(secs_left) + " seconds left."
                                    msgdialogprogress.update(
                                        percent,
                                        str(_timer["channel"].decode("utf-8")),
                                        str(_timer["title"].decode("utf-8")),
                                        remaining_display,
                                    )
                                    xbmc.sleep(1000)
                                    if msgdialogprogress.iscanceled():
                                        switchAborted = True
                                        break
                                msgdialogprogress.close()

                            else:
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30026) % (_timer["channel"].decode("utf-8")),
                                    time=self.__dispMsgTime,
                                )

                                # wait for for cancelling by user (Ennieki ;)

                                while countdown < self.__dispMsgTime / 1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break
                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    countdown += 1

                            if switchAborted:
                                handler.notifyLog("Channelswitch cancelled by user")
                            else:
                                if plrProps["player"] == "audio" or (
                                    plrProps["player"] == "video" and plrProps["media"] != "channel"
                                ):
                                    # stop the media player
                                    handler.notifyLog(
                                        "player:%s media:%s @id:%s is running"
                                        % (plrProps["player"], plrProps["media"], plrProps["playerid"])
                                    )
                                    query = {
                                        "jsonrpc": "2.0",
                                        "method": "Player.Stop",
                                        "params": {"playerid": plrProps["playerid"]},
                                        "id": 1,
                                    }
                                    res = jsonrpc(query)
                                    # is this faster?
                                    # xbmc.executebuiltin('PlayerControl(Stop)')
                                    if "result" in res and res["result"] == "OK":
                                        handler.notifyLog("Player stopped")

                                handler.notifyLog(
                                    "Currently playing channelid %s, switch to id %s" % (plrProps["id"], chanIdTmr)
                                )
                                query = {
                                    "jsonrpc": "2.0",
                                    "id": 1,
                                    "method": "Player.Open",
                                    "params": {"item": {"channelid": chanIdTmr}},
                                }
                                res = jsonrpc(query)
                                if "result" in res and res["result"] == "OK":
                                    handler.notifyLog("Switched to channel '%s'" % (_timer["channel"].decode("utf-8")))
                                else:
                                    handler.notifyLog(
                                        "Couldn't switch to channel '%s'" % (_timer["channel"].decode("utf-8"))
                                    )
                                    handler.notifyOSD(
                                        __LS__(30000),
                                        __LS__(30025) % (_timer["channel"].decode("utf-8")),
                                        icon=__IconAlert__,
                                    )

                        self.resetSwitchTimer(_timer["channel"], _timer["date"])
                        handler.notifyLog("Timer @%s deactivated" % (_timer["date"]))

        handler.notifyLog("Service kicks off")
예제 #11
0
import xbmc
import handler

if __name__ ==  '__main__':

    handler.notifyLog('Parameter handler called: add Timer')
    try:
        args = {'channel':xbmc.getInfoLabel('ListItem.ChannelName'),
                'icon':xbmc.getInfoLabel('ListItem.Icon'),
                'date':xbmc.getInfoLabel('ListItem.Date'),
                'title':xbmc.getInfoLabel('ListItem.Title')
                }

        if not handler.setSwitchTimer(args['channel'], args['icon'], args['date'], args['title']):
            handler.notifyLog('Timer couldn\'t or wouldn\'t set', xbmc.LOGERROR)
    except Exception, e:
            handler.notifyLog('Script error, Timer couldn\'t set', xbmc.LOGERROR)
예제 #12
0
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL):
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            _switchInstantly = False
            plrProps = self.getPlayer()

            for _timer in self.timers:

                if not _timer['utime']:
                    handler.notifyLog(
                        'Couldn\'t calculate timestamp, delete timer',
                        xbmc.LOGERROR)
                    self.resetTmr(_timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetTmr(_timer['date'])
                    continue

                if _timer['utime'] < _now: _switchInstantly = True
                if (_timer['utime'] - _now < INTERVAL +
                        self.__dispMsgTime / 1000) or _switchInstantly:
                    chanIdTmr = self.channelName2channelId(_timer['channel'])
                    if chanIdTmr:

                        # compare with player properties, switch if necessary

                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30027) %
                                (_timer['title'], _timer['channel']),
                                time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog('Channel switch to %s required' %
                                              (_timer['channel']))

                            if _switchInstantly:
                                handler.notifyLog(
                                    'immediate channel switching required')
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30027) %
                                    (_timer['title'], _timer['channel']),
                                    time=5000)

                            elif not self.__showNoticeBeforeSw:
                                xbmc.sleep(self.__dispMsgTime)

                            elif self.__useCountdownTimer:
                                handler.OSDProgress.create(
                                    __LS__(30028),
                                    __LS__(30026) %
                                    (_timer['channel'], _timer['title']),
                                    __LS__(30029) %
                                    (int(self.__dispMsgTime / 1000 - secs)))
                                while secs < self.__dispMsgTime / 1000:
                                    secs += 1
                                    percent = int(
                                        (secs * 100000) / self.__dispMsgTime)
                                    handler.OSDProgress.update(
                                        percent,
                                        __LS__(30026) %
                                        (_timer['channel'], _timer['title']),
                                        __LS__(30029) %
                                        (int(self.__dispMsgTime / 1000 -
                                             secs)))
                                    xbmc.sleep(1000)
                                    if (handler.OSDProgress.iscanceled()):
                                        switchAborted = True
                                        break
                                handler.OSDProgress.close()
                            else:
                                idleTime = xbmc.getGlobalIdleTime()
                                handler.notifyOSD(
                                    __LS__(30000),
                                    __LS__(30026) %
                                    (_timer['channel'], _timer['title']),
                                    time=self.__dispMsgTime)
                                while secs < self.__dispMsgTime / 1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break

                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    secs += 1
                                if switchAborted:
                                    handler.notifyOSD(__LS__(30000),
                                                      __LS__(30032))

                            if switchAborted:
                                handler.notifyLog(
                                    'Channelswitch cancelled by user')
                            else:
                                self.has_started = False
                                self.switchToChannelId(plrProps, chanIdTmr,
                                                       _timer['channel'])

                    self.resetTmr(_timer['date'])

            if self.has_started and self.switchOnInit and self.channel > 0:
                handler.notifyLog('Channelswitch on startup enabled')
                query = {
                    "method": "PVR.GetChannels",
                    "params": {
                        "channelgroupid": "alltv",
                        "properties": ["channelnumber"]
                    }
                }
                res = jsonrpc(query)
                if 'result' in res:
                    for _channel in res['result']['channels']:
                        if _channel['channelnumber'] == self.channel:
                            handler.notifyLog(
                                'Channelswitch on startup is enabled, switch to \'%s\''
                                % (_channel['label']))
                            handler.notifyOSD(
                                __LS__(30000),
                                __LS__(30013) % (_channel['label']))
                            self.switchToChannelId(plrProps,
                                                   _channel['channelid'],
                                                   _channel['label'])
                            self.has_started = False
                            break

            self.timers = handler.getTimer()

        handler.notifyLog('Service kicks off')
예제 #13
0
    def poll(self):

        while not knClasses.XBMCMonitor.abortRequested(self):

            if knClasses.XBMCMonitor.waitForAbort(self, INTERVAL): break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            _switchInstantly = False
            plrProps = self.getPlayer()

            for _timer in self.timers:

                if not _timer['utime']:
                    handler.notifyLog('Couldn\'t calculate timestamp, delete timer', xbmc.LOGERROR)
                    self.resetTmr(_timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetTmr(_timer['date'])
                    continue

                if _timer['utime'] - self.__leadOffset < _now: _switchInstantly = True
                if (_timer['utime'] - _now < INTERVAL + self.__dispMsgTime / 1000 + self.__leadOffset) or _switchInstantly:
                    chanIdTmr = self.channelName2channelId(_timer['channel'])
                    if chanIdTmr:

                        # compare with player properties, switch if necessary

                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(loc(30000), loc(30027) % (_timer['title'], _timer['channel']), time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog('Channel switch to %s required' % (_timer['channel']))

                            if _switchInstantly:
                                handler.notifyLog('immediate channel switching required')
                                handler.notifyOSD(loc(30000), loc(30027) % (_timer['title'], _timer['channel']), time=5000)
                            elif not self.__showNoticeBeforeSw: xbmc.sleep(self.__dispMsgTime)
                            elif self.__useCountdownTimer:
                                if os.path.exists(os.path.join(path, 'resources', 'skins', 'Default', '1080i', SKIN)):

                                    try:
                                        pvr = knClasses.cPvrProperties()
                                        pvrprops = dict()
                                        recEnabled = True
                                        pvrprops.update(pvr.getRecordingCapabilities(
                                            self.channelName2channelId(_timer['channel']), _timer['utime']))
                                        if pvrprops['hastimer']: recEnabled = False
                                    except (pvr.PvrAddTimerException, pvr.JsonExecException), e:
                                        handler.notifyLog(str(e), xbmc.LOGERROR)
                                        recEnabled = False

                                    Popup = knClasses.cNotification(SKIN, path, message=loc(30035) % (_timer['title'], _timer['channel']),
                                                          timer=self.__dispMsgTime/1000, icon=_timer['icon'], recEnabled=recEnabled)
                                    Popup.doModal()
                                    if Popup.isCanceled: switchAborted = True
                                    elif Popup.initRecording:
                                        try:
                                            pvr.setTimer(pvrprops['broadcastid'])
                                            handler.notifyLog('Recording schedule set for %s: %s' % (_timer['channel'], _timer['title']), xbmc.LOGNOTICE)
                                            switchAborted = True
                                        except (pvr.PvrAddTimerException, pvr.JsonExecException), e:
                                            handler.notifyOSD(loc(30000), loc(30036) % (_timer['title'], _timer['channel']), icon=IconAlert)
                                            handler.notifyLog(str(e), xbmc.LOGERROR)
                                    elif Popup.requestSwitch:
                                        handler.notifyLog('immediate channel switch initate by user')
                                    else:
                                        handler.notifyLog('Window countdown completed without user action')
                                else:
                                    handler.OSDProgress.create(loc(30028), loc(30026) %
                                                               (_timer['channel'], _timer['title']),
                                                               loc(30029) % (int(self.__dispMsgTime / 1000 - secs)))
                                    while secs < self.__dispMsgTime /1000:
                                        secs += 1
                                        percent = int((secs * 100000) / self.__dispMsgTime)
                                        handler.OSDProgress.update(percent, loc(30026) %
                                                                   (_timer['channel'], _timer['title']),
                                                                   loc(30029) % (int(self.__dispMsgTime / 1000 - secs)))
                                        xbmc.sleep(1000)
                                        if (handler.OSDProgress.iscanceled()):
                                            switchAborted = True
                                            break
                                    handler.OSDProgress.close()
                            else:
                                idleTime = xbmc.getGlobalIdleTime()
                                handler.notifyOSD(loc(30000), loc(30026) %
                                                  (_timer['channel'], _timer['title']), time=self.__dispMsgTime)
                                while secs < self.__dispMsgTime /1000:
                                    if idleTime > xbmc.getGlobalIdleTime():
                                        switchAborted = True
                                        break

                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    secs += 1
                                if switchAborted: handler.notifyOSD(loc(30000), loc(30032))

                            if switchAborted: handler.notifyLog('Channelswitch cancelled by user')
                            else:
                                self.bootstrap = False
                                self.switchToChannelId(plrProps, chanIdTmr, _timer['channel'])

                    self.resetTmr(_timer['date'])
예제 #14
0
                                        break

                                    xbmc.sleep(1000)
                                    idleTime += 1
                                    secs += 1
                                if switchAborted: handler.notifyOSD(loc(30000), loc(30032))

                            if switchAborted: handler.notifyLog('Channelswitch cancelled by user')
                            else:
                                self.bootstrap = False
                                self.switchToChannelId(plrProps, chanIdTmr, _timer['channel'])

                    self.resetTmr(_timer['date'])

            if self.bootstrap and self.__switchOnInit and self.__channel > 0:
                handler.notifyLog('Channelswitch on startup enabled')
                query = {
                        "method": "PVR.GetChannels",
                        "params": {"channelgroupid": "alltv", "properties": ["channelnumber"]}
                        }
                res = jsonrpc(query)
                if 'result' in res:
                    for _channel in res['result']['channels']:
                        if _channel['channelnumber'] == self.__channel:
                            handler.notifyLog('Channelswitch on startup is enabled, switch to \'%s\'' % (_channel['label']))
                            handler.notifyOSD(loc(30000), loc(30013) % (_channel['label']))
                            self.switchToChannelId(plrProps, _channel['channelid'], _channel['label'])
                            self.bootstrap = False
                            break

            self.timers = handler.getTimer()
예제 #15
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import xbmcgui
import handler

if __name__ == '__main__':

    handler.notifyLog('Context menu called: del event')

    # fetch own announcements

    args = dict()
    broadcast = dict()
    args.update({'command': 'fetch'})
    bc = handler.cRequestConnector()
    result = bc.transmitAnnouncement(args)

    if result is not None:
        fetched = result['items']
        if len(fetched) > 0:

            menu = list()

            for item in fetched:
                liz = xbmcgui.ListItem(label=item['Title'],
                                       label2='%s - %s' %
                                       (item['ChannelName'], item['Date']))
                liz.setArt({'icon': item['Icon']})
                liz.setProperty('file', item['File'])
                menu.append(liz)
예제 #16
0
파일: deltimer.py 프로젝트: kodinerds/repo
import xbmc
import handler

if __name__ ==  '__main__':

    handler.notifyLog('Parameter handler called: Delete Timerlist')
    try:
        if not handler.clearTimerList():
            handler.notifyLog('Timerlist couldn\'t deleted', xbmc.LOGERROR)
    except Exception, e:
            handler.notifyLog('Script error, Timer couldn\'t deleted', xbmc.LOGERROR)
예제 #17
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import xbmc
import handler

if __name__ == '__main__':

    handler.notifyLog('Parameter handler called: add timer')
    args = {
        'channel': xbmc.getInfoLabel('ListItem.ChannelName'),
        'icon': xbmc.getInfoLabel('ListItem.Icon'),
        'date': xbmc.getInfoLabel('ListItem.Date'),
        'title': xbmc.getInfoLabel('ListItem.Title'),
        'plot': xbmc.getInfoLabel('ListItem.Plot')
    }

    if not handler.setTimer(args):
        handler.notifyLog('Timer couldn\'t or wouldn\'t be set')
예제 #18
0
    def poll(self):

        while not XBMCMonitor.abortRequested(self):

            if XBMCMonitor.waitForAbort(self, INTERVAL): 
                break
            if self.SettingsChanged:
                self.getSettings()

            _now = time.time()
            timers = handler.readTimerStrings()
            for _timer in timers:

                if not _timer['utime']:
                    handler.notifyLog('Couldn\'t calculate timestamp, delete timer', xbmc.LOGERROR)
                    self.resetSwitchTimer(_timer['channel'], _timer['date'])
                    break

                # delete old/discarded timers
                if _timer['utime'] + self.__discardTmr < _now:
                    self.resetSwitchTimer(_timer['channel'], _timer['date'])
                    continue

                _timediff = INTERVAL + self.__dispMsgTime/1000
                if _timer['utime'] - _now < _timediff:
                    chanIdTmr = self.channelName2channelId(_timer['channel'].decode('utf-8'))
                    if chanIdTmr:

                        # get player properties, switch if necessary

                        plrProps = self.getPlayer()
                        if chanIdTmr == plrProps['id']:
                            handler.notifyLog('Channel switching unnecessary')
                            handler.notifyOSD(__LS__(30000), __LS__(30027) % (_timer['channel'].decode('utf-8')), time=self.__dispMsgTime)
                        else:
                            switchAborted = False
                            secs = 0
                            handler.notifyLog('Channel switch to %s required' %  (_timer['channel'].decode('utf-8')))

                            if self.__showNoticeBeforeSw:
                                if self.__useCountdownTimer:
                                    percent = 0
                                    handler.OSDProgress.create(__LS__(30028), _timer['channel'].decode('utf-8'), _timer['title'].decode('utf-8'), __LS__(30029) % (int(self.__dispMsgTime/1000 - secs)))
                                    while secs < self.__dispMsgTime/1000:
                                        secs += 1
                                        percent = int((secs * 100)/self.__dispMsgTime)
                                        handler.OSDProgress.update(percent, _timer['channel'].decode('utf-8'), _timer['title'].decode('utf-8'), __LS__(30029) % (int(self.__dispMsgTime/1000 - secs)))
                                        xbmc.sleep(1000)
                                        if (handler.OSDProgress.iscanceled()):
                                            switchAborted = True
                                            break
                                    handler.OSDProgress.close()
                                else:
                                    idleTime = xbmc.getGlobalIdleTime()
                                    handler.notifyOSD(__LS__(30000), __LS__(30026) % (_timer['channel'].decode('utf-8')), time=self.__dispMsgTime)

                                    # wait for for cancelling by user (Ennieki ;)

                                    while secs < self.__dispMsgTime/1000:
                                        if idleTime > xbmc.getGlobalIdleTime():
                                            switchAborted = True
                                            break
                                        xbmc.sleep(1000)
                                        idleTime += 1
                                        secs += 1
                            else:
                                xbmc.sleep(self.__dispMsgTime)
 
                            if switchAborted:
                                handler.notifyLog('Channelswitch cancelled by user')
                            else:
                                if plrProps['player'] == 'audio' or (plrProps['player'] == 'video' and plrProps['media'] != 'channel'):

                                    # stop all other players except pvr

                                    handler.notifyLog('player:%s media:%s @id:%s is running' % (plrProps['player'], plrProps['media'], plrProps['playerid']))
                                    query = {
                                            "jsonrpc": "2.0",
                                            "method": "Player.Stop",
                                            "params": {"playerid": plrProps['playerid']},
                                            "id": 1
                                            }
                                    res = jsonrpc(query)
                                    if 'result' in res and res['result'] == "OK":
                                        handler.notifyLog('Player stopped')

                                handler.notifyLog('Currently playing channelid %s, switch to id %s' % (plrProps['id'], chanIdTmr))
                                query = {
                                        "jsonrpc": "2.0",
                                        "id": 1,
                                        "method": "Player.Open",
                                        "params": {"item": {"channelid": chanIdTmr}}
                                        }
                                res = jsonrpc(query)
                                if 'result' in res and res['result'] == 'OK':
                                    handler.notifyLog('Switched to channel \'%s\'' % (_timer['channel'].decode('utf-8')))
                                else:
                                    handler.notifyLog('Couldn\'t switch to channel \'%s\'' % (_timer['channel'].decode('utf-8')))
                                    handler.notifyOSD(__LS__(30000), __LS__(30025) % (_timer['channel'].decode('utf-8')), icon=__IconAlert__)

                        self.resetSwitchTimer(_timer['channel'], _timer['date'])
                        handler.notifyLog('Timer @%s deactivated' % (_timer['date']))

        handler.notifyLog('Service kicks off')
예제 #19
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import xbmc
import handler

if __name__ == '__main__':

    handler.notifyLog('Context menu called: add event')
    handler.notifyLog('Local time format of client: {}'.format(
        handler.regionDateFormat()))

    args = dict()
    broadcast = dict()
    broadcast.update({
        'channelname':
        xbmc.getInfoLabel('ListItem.ChannelName'),
        'icon':
        xbmc.getInfoLabel('ListItem.Icon'),
        'date':
        handler.date2JTF(xbmc.getInfoLabel('ListItem.Date')),
        'starttime':
        handler.date2JTF(xbmc.getInfoLabel('ListItem.StartTime'),
                         timeonly=True),
        'endtime':
        handler.date2JTF(xbmc.getInfoLabel('ListItem.EndTime'), timeonly=True),
        'title':
        xbmc.getInfoLabel('ListItem.Title'),
        'epgeventtitle':
        xbmc.getInfoLabel('ListItem.EpgEventTitle'),
        'genre':
예제 #20
0
 def __init__(self, *args):
     XBMCMonitor.__init__(self)
     self.__dateFormat = None
     self.activeTimers = 0
     self.getSettings()
     handler.notifyLog('Init Service %s %s' % (__addonname__, __version__))