def select_ovpn(): global _state ovpnfiles = [] for path in os.listdir(_userdata): if os.path.splitext(path)[1] == '.ovpn': log_debug('Found configuration: [%s]' % path) ovpnfiles.append(path) if len(ovpnfiles) == 0: return None else: ovpnfiles.sort() response = vpn.is_running(_ip, _port) log_debug('Response from is_running: [%s] [%s] [%s]' % ( response[0], response[1], response[2])) if response[0]: _state = connected ovpnfiles.append(_settings.get_string(3014)) configs = [] for ovpn in ovpnfiles: config = os.path.splitext(ovpn)[0] if response[1] is not None and response[2] is not None and config == os.path.splitext(os.path.basename(response[1]))[0]: config = '%s - %s' % (config, response[2]) configs.append(config) idx = utils.select(_settings.get_string(3013), configs) if idx >= 0: log_debug('Select: [%s]' % ovpnfiles[idx]) return ovpnfiles[idx] else: return ''
def select_ovpn(): global _state ovpnfiles = [] for path in os.listdir(_userdata): if os.path.splitext(path)[1] == '.ovpn': log_debug('Found configuration: [%s]' % path) ovpnfiles.append(path) if len(ovpnfiles) == 0: return None else: ovpnfiles.sort() response = vpn.is_running(_ip, _port) log_debug('Response from is_running: [%s] [%s] [%s]' % (response[0], response[1], response[2])) if response[0]: _state = connected ovpnfiles.append(_settings.get_string(3014)) configs = [] for ovpn in ovpnfiles: config = os.path.splitext(ovpn)[0] if response[1] is not None and response[ 2] is not None and config == os.path.splitext( os.path.basename(response[1]))[0]: config = '%s - %s' % (config, response[2]) configs.append(config) idx = utils.select(_settings.get_string(3013), configs) if idx >= 0: log_debug('Select: [%s]' % ovpnfiles[idx]) return ovpnfiles[idx] else: return ''
def live(): choice = 0 live_videos = [video for video in youtubelib.get_live_videos()] if not live_videos: kodiutils.notification(ADDON_NAME, kodiutils.get_string(32009)) return elif len(live_videos) > 1: choice = kodiutils.select(kodiutils.get_string(32010), [video["label"] for video in live_videos]) if choice > -1: stream = 'plugin://plugin.video.youtube/play/?video_id=%s' % ( live_videos[choice]["video_id"]) liz = ListItem() liz.setPath(stream) xbmcplugin.setResolvedUrl(plugin.handle, True, liz)
def get_uri_by_timestamp(cls): """Generate an URI based on the timestamp.""" program = cls._get_selection() if not program: return None # Get a list of addons that can play the selected channel # We do the lookup based on Channel Name, since that's all we have try: addons = cls._get_addons_for_channel(program.get('channel')) except IOError: if kodiutils.yesno_dialog(message=kodiutils.localize( 30713)): # The EPG data is not up to date... from resources.lib.modules.addon import Addon Addon.refresh(True) return None if not addons: # Channel was not found. _LOGGER.debug('No Add-on was found to play %s', program.get('channel')) kodiutils.notification(message=kodiutils.localize( 30710, channel=program.get('channel'))) # Could not find an Add-on... return None if len(addons) == 1: # Channel has one Add-on. Play it directly. _LOGGER.debug('One Add-on was found to play %s: %s', program.get('channel'), addons) return cls._format_uri(list(addons.values())[0], program) # Ask the user to pick an Add-on _LOGGER.debug('Multiple Add-on were found to play %s: %s', program.get('channel'), addons) addons_list = list(addons) ret = kodiutils.select(heading=kodiutils.localize(30711), options=addons_list) # Select an Add-on... if ret == -1: _LOGGER.debug('The selection to play an item from %s was canceled', program.get('channel')) return None return cls._format_uri(addons.get(addons_list[ret]), program)
def onAction(self, action): actionid = action.getId() # if actionid != 107: # print 'onAction: %s' % actionid if actionid == _action_previous_menu or actionid == _action_nav_back: self.close() elif actionid == _action_select_item: if self._layertype == _layer_type_hybrid: self._layertype = 0 else: self._layertype += 1 self.set_tiles() elif actionid == _action_move_left or actionid == _action_move_right or actionid == _action_move_up or actionid == _action_move_down: if actionid == _action_move_left: self._centre_tilex -= 1 elif actionid == _action_move_right: self._centre_tilex += 1 elif actionid == _action_move_up: self._centre_tiley -= 1 elif actionid == _action_move_down: self._centre_tiley += 1 self._lat_deg, self._lon_deg = self.num2deg( self._centre_tilex, self._centre_tiley, self._zoom) self.set_tiles() elif actionid == _action_page_up or actionid == _action_page_down: if actionid == _action_page_up: if self._zoom < _map_max_zoom: self._zoom += 1 elif actionid == _action_page_down: if self._zoom > _map_min_zoom: self._zoom -= 1 self._centre_tilex, self._centre_tiley, self._home_pixelx, self._home_pixely = self.deg2num( self._lat_deg, self._lon_deg, self._zoom) self._home_column, self._home_row, self._home_pixelx, self._home_pixely = self.deg2num( self._home_lat_deg, self._home_lon_deg, self._zoom) self.set_tiles() elif actionid == _action_context_menu: query = utils.keyboard('', heading=self._settings.get_string(3001)) if query and len(query) > 0: if self._settings.get('api') == 0: osm = mapsapi.OpenStreetMapApi() else: osm = mapsapi.MapQuestOpenApi() response = osm.search(query) if len(response) > 0: index = 0 if len(response) > 1: displaynames = [] for result in response: displaynames.append(result['display_name']) index = utils.select(self._settings.get_string(3002), displaynames) if index >= 0 and index < len(response): self._home_lat_deg = self._lat_deg = float( response[index]['lat']) self._home_lon_deg = self._lon_deg = float( response[index]['lon']) self._centre_tilex, self._centre_tiley, self._home_pixelx, self._home_pixely = self.deg2num( self._lat_deg, self._lon_deg, self._zoom) self._home_column = self._centre_tilex self._home_row = self._centre_tiley self.set_tiles() else: utils.ok(self._settings.get_string(3000), self._settings.get_string(3003) % query, self._settings.get_string(3004))