Ejemplo n.º 1
0
 def __init__(self, pluginId, pluginDisplayName, pluginVersion,
              pluginPrefs):
     indigo.PluginBase.__init__(self, pluginId, pluginDisplayName,
                                pluginVersion, pluginPrefs)
     self.plexApi = PlexApi(pluginPrefs.get('address'),
                            pluginPrefs.get('port'))
     self.debug = pluginPrefs.get('showDebugInfo', False)
Ejemplo n.º 2
0
    def testGetClientMachineIds_no_results(self):
        real = PlexApi("foo", "bar")
        real.getStatusSession = Mock(return_value='''
                <MediaContainer size="0">
                </MediaContainer>
            ''')

        machineIds = real.getClientMachineIds()
        assert isinstance(machineIds, list)
        self.assertEqual(0, len(machineIds))
Ejemplo n.º 3
0
    def testGetClientMachineIds(self):
        real = PlexApi("foo", "bar")
        machineId1 = '''TestMI1'''
        machineId2 = '''TestMI2'''
        real.getStatusSession = Mock(return_value=('''
                <MediaContainer size="1">
                    <Video>
                        <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="paused" title="HTPC" />
                        <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="paused" title="HTPC" />
                    </Video>
                </MediaContainer>
            ''' % (machineId1, machineId2)))

        machineIds = real.getClientMachineIds()
        assert isinstance(machineIds, list)
        self.assertEqual(2, len(machineIds))
        self.assertEqual(machineId1, machineIds[0])
        self.assertEqual(machineId2, machineIds[1])
Ejemplo n.º 4
0
    def testGetClientState(self):
        real = PlexApi("foo", "bar")
        machineId1 = 'TestMI1'
        machineId2 = 'TestMI2'
        real.getStatusSession = Mock(return_value=('''
                <MediaContainer size="1">
                    <Video>
                        <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="paused" title="HTPC" />
                        <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="playing" title="HTPC" />
                    </Video>
                </MediaContainer>
            ''' % (machineId1, machineId2)))

        state = real.getClientState(machineId1)
        self.assertEqual('paused', state)
        state = real.getClientState(machineId2)
        self.assertEqual('playing', state)
        state = real.getClientState('unknownMI')
        self.assertEqual('client_offline', state)
Ejemplo n.º 5
0
 def closedPrefsConfigUi(self, valuesDict, userCancelled):
     if not userCancelled:
         address = valuesDict.get(u"address")
         port = valuesDict.get(u"port")
         self.debugLog(u"Plex Server " + address + ":" + port)
         self.plexApi = PlexApi(address, port)