def root(self, pathitems=None): # pylint: disable=unused-argument """Show profiles or home listing when profile auto-selection is enabled""" # Get the URL parent path of the navigation: xbmc.getInfoLabel('Container.FolderPath') # it can be found in Kodi log as "ParentPath = [xyz]" but not always return the exact value is_parent_root_path = xbmc.getInfoLabel( 'Container.FolderPath') == G.BASE_URL + '/' # Fetch initial page to refresh all session data if is_parent_root_path and not G.IS_CONTAINER_REFRESHED: common.make_call('fetch_initial_page') # Note when the profiles are updated to the database (by fetch_initial_page call), # the update sanitize also relative settings to profiles (see _delete_non_existing_profiles in website.py) autoselect_profile_guid = G.LOCAL_DB.get_value( 'autoselect_profile_guid', '') if autoselect_profile_guid and not G.IS_CONTAINER_REFRESHED: if is_parent_root_path: LOG.info('Performing auto-selection of profile {}', autoselect_profile_guid) # Do not perform the profile switch if navigation come from a page that is not the root url, # prevents profile switching when returning to the main menu from one of the sub-menus if not is_parent_root_path or activate_profile( autoselect_profile_guid): self.home(None, True) return # IS_CONTAINER_REFRESHED is temporary set from the profiles context menu actions # to avoid perform the fetch_initial_page/auto-selection every time when the container will be refreshed G.IS_CONTAINER_REFRESHED = False list_data, extra_data = common.make_call('get_profiles', {'request_update': False}) self._profiles(list_data, extra_data)
def _profile_switch(): """Profile switch to play from the library""" # This is needed to play videos with the appropriate Netflix profile to avoid problems like: # Missing audio/subtitle languages; Missing metadata; Wrong age restrictions; # Video content not available; Sync with netflix watched status to wrong profile # Of course if the user still selects the wrong profile the problems remains, # but now will be caused only by the user for inappropriate use. is_playback_ask_profile = G.ADDON.getSettingBool( 'library_playback_ask_profile') if is_playback_ask_profile or not G.LOCAL_DB.get_value( 'library_playback_profile_guid'): selected_guid = ui.show_profiles_dialog( title_prefix=common.get_local_string(15213), preselect_guid=G.LOCAL_DB.get_active_profile_guid()) else: selected_guid = G.LOCAL_DB.get_value('library_playback_profile_guid') if selected_guid: if not is_playback_ask_profile: # Save the selected profile guid G.LOCAL_DB.set_value('library_playback_profile_guid', selected_guid) # Save the selected profile name G.ADDON.setSetting( 'library_playback_profile', G.LOCAL_DB.get_profile_config('profileName', '???', guid=selected_guid)) # Perform the profile switch # The profile switch is done to NFSession, the MSL part will be switched automatically from resources.lib.navigation.directory_utils import activate_profile if not activate_profile(selected_guid): return False else: return False return True
def home(self, pathitems=None): # pylint: disable=unused-argument """Show home listing""" if 'switch_profile_guid' in self.params: if G.IS_ADDON_EXTERNAL_CALL: # Profile switch/ask PIN only once ret = not self.params[ 'switch_profile_guid'] == G.LOCAL_DB.get_active_profile_guid( ) else: # Profile switch/ask PIN every time you come from ... ret = common.WndHomeProps[ common.WndHomeProps.CURRENT_DIRECTORY] in [ '', 'root', 'profiles' ] if ret and not activate_profile( self.params['switch_profile_guid']): xbmcplugin.endOfDirectory(G.PLUGIN_HANDLE, succeeded=False) return LOG.debug('Showing home listing') list_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable finalize_directory( convert_list_to_dir_items(list_data), G.CONTENT_FOLDER, title=(G.LOCAL_DB.get_profile_config('profileName', '???') + ' - ' + common.get_local_string(30097))) end_of_directory(True)
def __init__(self, params): LOG.debug('Initializing "Directory" with params: {}', params) self.params = params # After build url the param value is converted as string self.perpetual_range_start = ( None if self.params.get('perpetual_range_start') == 'None' else self.params.get('perpetual_range_start')) if 'dir_update_listing' in self.params: self.dir_update_listing = self.params[ 'dir_update_listing'] == 'True' else: self.dir_update_listing = bool(self.perpetual_range_start) if self.perpetual_range_start == '0': # For cache identifier purpose self.perpetual_range_start = None if 'switch_profile_guid' in params: guid_passed = self.params.get('guid') guid_active = G.LOCAL_DB.get_active_profile_guid() if guid_passed != '' and guid_passed != guid_active: activate_profile(params['switch_profile_guid'])
def home(self, pathitems=None, cache_to_disc=True, is_autoselect_profile=False): # pylint: disable=unused-argument """Show home listing""" if not is_autoselect_profile and 'switch_profile_guid' in self.params: # This is executed only when you have selected a profile from the profile list if not activate_profile(self.params['switch_profile_guid']): xbmcplugin.endOfDirectory(G.PLUGIN_HANDLE, succeeded=False) return LOG.debug('Showing home listing') list_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable finalize_directory(convert_list_to_dir_items(list_data), G.CONTENT_FOLDER, title=(G.LOCAL_DB.get_profile_config('profileName', '???') + ' - ' + common.get_local_string(30097))) end_of_directory(True, cache_to_disc)
def home(self, pathitems=None): # pylint: disable=unused-argument """Show home listing""" if 'switch_profile_guid' in self.params and G.CURRENT_LOADED_DIRECTORY in [ None, 'root', 'profiles' ]: if not activate_profile(self.params['switch_profile_guid']): xbmcplugin.endOfDirectory(G.PLUGIN_HANDLE, succeeded=False) return LOG.debug('Showing home listing') list_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable finalize_directory( convert_list_to_dir_items(list_data), G.CONTENT_FOLDER, title=(G.LOCAL_DB.get_profile_config('profileName', '???') + ' - ' + common.get_local_string(30097))) end_of_directory(True)