Exemple #1
0
 def __init__(self, address, password):
     self.signals = kaa.Signals('connected', 'disconnected', 'changed')
     self.recordings = Recordings(self)
     self.favorites = Favorites(self)
     self.channel = kaa.rpc.connect(address, password, retry=1)
     self.channel.register(self)
     self.channel.signals['open'].connect(self._connected)
     self.channel.signals['closed'].connect(self._disconnected)
     # connect kaa.epg database to port + 1
     address, port = address.split(':')
     kaa.epg.connect('%s:%s' % (address, int(port) + 1), password)
Exemple #2
0
 def __init__(self, address, password):
     self.signals = kaa.Signals('connected', 'disconnected', 'changed')
     self.recordings = Recordings(self)
     self.favorites = Favorites(self)
     self.channel = kaa.rpc.connect(address, password, retry=1)
     self.channel.register(self)
     self.channel.signals['open'].connect(self._connected)
     self.channel.signals['closed'].connect(self._disconnected)
     # connect kaa.epg database to port + 1
     address, port = address.split(':')
     kaa.epg.connect('%s:%s' % (address, int(port) + 1), password)
Exemple #3
0
class TVServer(object):
    def __init__(self, address, password):
        self.signals = kaa.Signals('connected', 'disconnected', 'changed')
        self.recordings = Recordings(self)
        self.favorites = Favorites(self)
        self.channel = kaa.rpc.connect(address, password, retry=1)
        self.channel.register(self)
        self.channel.signals['open'].connect(self._connected)
        self.channel.signals['closed'].connect(self._disconnected)
        # connect kaa.epg database to port + 1
        address, port = address.split(':')
        kaa.epg.connect('%s:%s' % (address, int(port) + 1), password)

    @kaa.coroutine()
    def _connected(self, *args):
        log.info('connected to tvserver')
        self.recordings._update((yield self.channel.rpc('recording_list')))
        self.favorites._update((yield self.channel.rpc('favorite_list')))
        self.signals['connected'].emit()

    def _disconnected(self):
        self.signals['disconnected'].emit()
        log.info('disconnected from tvserver')
        self.recordings._clear()
        self.favorites._clear()

    @property
    def connected(self):
        return self.channel.status == kaa.rpc.CONNECTED

    def recording_add(self, name, channel, priority, start, stop, **info):
        """
        Schedule a recording

        @param name: name of the program
        @param channel: name of the channel
        @param start: start time in UTC
        @param stop: stop time in UTC
        @param info: additional information
        @returns: InProgress object
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('recording_add', name, channel, priority,
                                start, stop, **info)

    def recording_remove(self, id):
        """
        Remove a recording

        @param id: id the the recording to be removed
        @returns: InProgress object
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('recording_remove', id)

    def favorite_update(self):
        """
        Check list of favorites against EPG and update
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('favorite_update')

    def favorite_add(self, title, channels, days, times, priority, once):
        """
        add a favorite

        @param channels: list of channel names are 'ANY'
        @param days: list of days ( 0 = Sunday - 6 = Saturday ) or 'ANY'
        @param times: list of hh:mm-hh:mm or 'ANY'
        @param priority: priority for the recordings
        @param once: True if only one recodring should be made
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        if channels == 'ANY':
            channels = [c.name for c in kaa.epg.get_channels()]
        if days == 'ANY':
            days = [0, 1, 2, 3, 4, 5, 6]
        if times == 'ANY':
            times = ['00:00-23:59']
        return self.channel.rpc('favorite_add', title, channels, priority,
                                days, times, once)

    def favorite_remove(self, id):
        """
        remove a favorite

        @param id: id of the favorite
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('favorite_remove', id)

    def favorite_modify(self, id, **kwargs):
        """
        @param id: id of the favorite
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('favorite_remove', id, **kwargs)

    @kaa.rpc.expose()
    def identify(self):
        return 'client'

    @kaa.rpc.expose('recording_update')
    def _recording_update(self, *recordings):
        self.recordings._update(recordings)
        self.signals['changed'].emit()

    @kaa.rpc.expose('favorite_update')
    def _favorite_update(self, *fav):
        self.recordings._update(fav)
        self.signals['changed'].emit()
Exemple #4
0
class TVServer(object):

    def __init__(self, address, password):
        self.signals = kaa.Signals('connected', 'disconnected', 'changed')
        self.recordings = Recordings(self)
        self.favorites = Favorites(self)
        self.channel = kaa.rpc.connect(address, password, retry=1)
        self.channel.register(self)
        self.channel.signals['open'].connect(self._connected)
        self.channel.signals['closed'].connect(self._disconnected)
        # connect kaa.epg database to port + 1
        address, port = address.split(':')
        kaa.epg.connect('%s:%s' % (address, int(port) + 1), password)

    @kaa.coroutine()
    def _connected(self, *args):
        log.info('connected to tvserver')
        self.recordings._update((yield self.channel.rpc('recording_list')))
        self.favorites._update((yield self.channel.rpc('favorite_list')))
        self.signals['connected'].emit()

    def _disconnected(self):
        self.signals['disconnected'].emit()
        log.info('disconnected from tvserver')
        self.recordings._clear()
        self.favorites._clear()

    @property
    def connected(self):
        return self.channel.status == kaa.rpc.CONNECTED

    def recording_add(self, name, channel, priority, start, stop, **info):
        """
        Schedule a recording

        @param name: name of the program
        @param channel: name of the channel
        @param start: start time in UTC
        @param stop: stop time in UTC
        @param info: additional information
        @returns: InProgress object
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('recording_add', name, channel, priority, start, stop, **info)

    def recording_remove(self, id):
        """
        Remove a recording

        @param id: id the the recording to be removed
        @returns: InProgress object
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('recording_remove', id)

    def favorite_update(self):
        """
        Check list of favorites against EPG and update
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('favorite_update')

    def favorite_add(self, title, channels, days, times, priority, once):
        """
        add a favorite

        @param channels: list of channel names are 'ANY'
        @param days: list of days ( 0 = Sunday - 6 = Saturday ) or 'ANY'
        @param times: list of hh:mm-hh:mm or 'ANY'
        @param priority: priority for the recordings
        @param once: True if only one recodring should be made
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        if channels == 'ANY':
            channels = [ c.name for c in kaa.epg.get_channels() ]
        if days == 'ANY':
            days = [ 0, 1, 2, 3, 4, 5, 6 ]
        if times == 'ANY':
            times = [ '00:00-23:59' ]
        return self.channel.rpc('favorite_add', title, channels, priority, days, times, once)

    def favorite_remove(self, id):
        """
        remove a favorite

        @param id: id of the favorite
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('favorite_remove', id)

    def favorite_modify(self, id, **kwargs):
        """
        @param id: id of the favorite
        """
        if not self.connected:
            raise RuntimeError('not connected to tvserver')
        return self.channel.rpc('favorite_remove', id, **kwargs)

    @kaa.rpc.expose()
    def identify(self):
        return 'client'

    @kaa.rpc.expose('recording_update')
    def _recording_update(self, *recordings):
        self.recordings._update(recordings)
        self.signals['changed'].emit()

    @kaa.rpc.expose('favorite_update')
    def _favorite_update(self, *fav):
        self.recordings._update(fav)
        self.signals['changed'].emit()