Example #1
0
        start()

    def stop(self):
        for t in self.threads:
            t.join()

                      

def start():
    """
    Function which starts the service.  Called on Kodi login as well as when restarted due to settings changes
    """
    
    settings.refreshAddonSettings()
    utils.log(1, 'SERVICE  :: **START**')
    utils.log(1, 'SERVICE  :: Log Level: %s' %utils.log_level())
    utils.log(1, 'SERVICE  :: Python Version: %s;  At Least 2.7: %s' %(sys.version, utils._atleast_python27))
    instance = service()
    instance.run(monitor) 


if __name__ == "__main__":                    
    monitor = monitor.AddonMonitor()
    start()
    monitor.waitForAbort(1)
    utils.cleanup_images()
        



    elif action == 'toggle_preview':
        monitor.togglePreview()

    
    # Update Fanart
    elif action == 'update_fanart':
        camera = Camera(camera_number)
        if camera.Connected(monitor, False):
            utils.get_fanart(camera_number, camera.getSnapShotUrl(), update = True)
            xbmc.executebuiltin('Container.Refresh')
            
        else:
            utils.notify(utils.translation(32222))


    # Restart Preview Service
    elif action == 'restart_service':
        monitor.stop()


    # Preliminary attempt to show an overlay based on a URL, not fully tested and does not close on its own yet
    elif action == 'show_preview_custom':
        url = params.get('url', '')
        if url != '':
            monitor.overrideURL(camera_number, url)
            monitor.openRequest_manual(camera_number)
        monitor.waitForAbort(2)
        monitor.clear_overrideURL(camera_number)
        
        
        xbmc.executebuiltin('Container.Refresh')

    # Toggle All Preview
    elif action == 'toggle_preview':
        monitor.togglePreview()

    # Update Fanart
    elif action == 'update_fanart':
        camera = Camera(camera_number)
        if camera.Connected(monitor, False):
            utils.get_fanart(camera_number,
                             camera.getSnapShotUrl(),
                             update=True)
            xbmc.executebuiltin('Container.Refresh')

        else:
            utils.notify(utils.translation(32222))

    # Restart Preview Service
    elif action == 'restart_service':
        monitor.stop()

    # Preliminary attempt to show an overlay based on a URL, not fully tested and does not close on its own yet
    elif action == 'show_preview_custom':
        url = params.get('url', '')
        if url != '':
            monitor.overrideURL(camera_number, url)
            monitor.openRequest_manual(camera_number)
        monitor.waitForAbort(2)
        monitor.clear_overrideURL(camera_number)