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()
def main_menu(): """ First Level Menu to access main functions """ if settings.atLeastOneCamera(): # All Camera Player addDirectoryItem(name = utils.translation(32027), icon = utils.get_icon('default'), fanart = utils.get_fanart('default'), parameters = {'action': 'all_cameras'}) for camera_number in "123456": if settings.enabled_camera(camera_number): camera = Camera(camera_number) list_label = settings.getCameraName(camera_number) # Build Context Menu li = li = xbmcgui.ListItem(list_label) context_items = [] if settings.getSetting('enabled_preview', camera_number) == 'true': #Show Preview context_items.append((utils.translation(32210), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=show_preview&camera_number=%s)' %camera_number)) #Disable Preview context_items.append((utils.translation(32212), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=disable_preview&camera_number=%s)' %camera_number)) else: #Enable Preview context_items.append((utils.translation(32211), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=enable_preview&camera_number=%s)' %camera_number)) camera_type = settings.getCameraType(camera_number) if camera_type < 3: #Play Stream no Controls context_items.append((utils.translation(32214), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=single_camera_no_controls&camera_number=%s)' %camera_number)) #Camera Settings context_items.append((utils.translation(32215), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=camera_settings&camera_number=%s)' %camera_number)) # Update Fanart if settings.getSetting_int('fanart') == 1: context_items.append((utils.translation(32213), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=update_fanart&camera_number=%s)' %camera_number)) li.addContextMenuItems(context_items, replaceItems=True) # Fanart URL new_art_url = None if camera.Connected(monitor): new_art_url = camera.getSnapShotUrl() else: if camera.Connected(monitor, False): new_art_url = camera.getSnapShotUrl() # Single Camera Player for enabled cameras addDirectoryItem(name = list_label, icon = utils.get_icon(camera_number), fanart = utils.get_fanart(camera_number, new_art_url), li = li, parameters = {'action': 'single_camera', 'camera_number': camera_number}) # Link to Second Level Advanced Menu addDirectoryItem(name = utils.translation(32029), isFolder = True, icon = utils.get_icon('advanced'), fanart = utils.get_fanart('default'), parameters={'action': 'advanced'}) else: # Add-on Settings if no cameras are configured addDirectoryItem(name = utils.translation(32028), icon = utils.get_icon('settings'), fanart = utils.get_fanart('default'), parameters = {'action': 'settings'}) xbmcplugin.endOfDirectory(handle=handle, succeeded=True) utils.cleanup_images()
def main_menu(): """ First Level Menu to access main functions """ if settings.atLeastOneCamera(): # All Camera Player addDirectoryItem(name=utils.translation(32027), icon=utils.get_icon('default'), fanart=utils.get_fanart('default'), parameters={'action': 'all_cameras'}) for camera_number in "123456": if settings.enabled_camera(camera_number): camera = Camera(camera_number) list_label = settings.getCameraName(camera_number) # Build Context Menu li = li = xbmcgui.ListItem(list_label) context_items = [] if settings.getSetting('enabled_preview', camera_number) == 'true': #Show Preview context_items.append((utils.translation( 32210 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=show_preview&camera_number=%s)' % camera_number)) #Disable Preview context_items.append((utils.translation( 32212 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=disable_preview&camera_number=%s)' % camera_number)) else: #Enable Preview context_items.append((utils.translation( 32211 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=enable_preview&camera_number=%s)' % camera_number)) camera_type = settings.getCameraType(camera_number) if camera_type < 3: #Play Stream no Controls context_items.append((utils.translation( 32214 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=single_camera_no_controls&camera_number=%s)' % camera_number)) #Camera Settings context_items.append((utils.translation( 32215 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=camera_settings&camera_number=%s)' % camera_number)) # Update Fanart if settings.getSetting_int('fanart') == 1: context_items.append((utils.translation( 32213 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=update_fanart&camera_number=%s)' % camera_number)) li.addContextMenuItems(context_items, replaceItems=True) # Fanart URL new_art_url = None if camera.Connected(monitor): new_art_url = camera.getSnapShotUrl() else: if camera.Connected(monitor, False): new_art_url = camera.getSnapShotUrl() # Single Camera Player for enabled cameras addDirectoryItem(name=list_label, icon=utils.get_icon(camera_number), fanart=utils.get_fanart( camera_number, new_art_url), li=li, parameters={ 'action': 'single_camera', 'camera_number': camera_number }) # Link to Second Level Advanced Menu addDirectoryItem(name=utils.translation(32029), isFolder=True, icon=utils.get_icon('advanced'), fanart=utils.get_fanart('default'), parameters={'action': 'advanced'}) else: # Add-on Settings if no cameras are configured addDirectoryItem(name=utils.translation(32028), icon=utils.get_icon('settings'), fanart=utils.get_fanart('default'), parameters={'action': 'settings'}) xbmcplugin.endOfDirectory(handle=handle, succeeded=True) utils.cleanup_images()