def run(params): # This is the entrypoint account_name = urllib.unquote(params.get('account', '')) account_settings = login.get_account(account_name) if account_settings: searchText = params.get('search_text', '') #check if a search text is already defined if searchText == '': #No search text defined, ask for it. keyboard = xbmc.Keyboard('', LANGUAGE_STRING(30018)) keyboard.doModal() if keyboard.isConfirmed(): searchText = keyboard.getText() params['search_text'] = searchText params['path'] = params.get('path', DROPBOX_SEP) if len(searchText) < 3: #Search text has to be atleast 3 chars dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30019)) xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False) else: search = DropboxSearch(params, account_settings) dialog = xbmcgui.DialogProgress() dialog.create(ADDON_NAME, LANGUAGE_STRING(30020), searchText) search.buildList() dialog.close() search.show() else: xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False)
def run(params): # This is the entrypoint account_name = urllib.unquote( params.get('account', '') ) account_settings = login.get_account(account_name) if account_settings: searchText = params.get('search_text', '') #check if a search text is already defined if searchText == '': #No search text defined, ask for it. keyboard = xbmc.Keyboard('', LANGUAGE_STRING(30018)) keyboard.doModal() if keyboard.isConfirmed(): searchText = keyboard.getText() params['search_text'] = searchText params['path'] = params.get('path', DROPBOX_SEP) if len(searchText) < 3: #Search text has to be atleast 3 chars dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30019) ) xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False) else: search = DropboxSearch(params, account_settings) dialog = xbmcgui.DialogProgress() dialog.create(ADDON_NAME, LANGUAGE_STRING(30020), searchText) search.buildList() dialog.close() search.show() else: xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False)
def run(params): # This is the entrypoint account_name = urllib.unquote(params.get('account', '')) account_settings = login.get_account(account_name) if account_settings: browser = FolderBrowser(params, account_settings) browser.buildList() browser.show() else: xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False)
def run(params): # This is the entrypoint account_name = urllib.unquote( params.get('account', '') ) account_settings = login.get_account(account_name) if account_settings: browser = FolderBrowser(params, account_settings) browser.buildList() browser.show() else: xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False)
def run(params): # This is the entrypoint action = params.get('action', '') if action == 'add': #add an account access_token = login.getAccessToken() if access_token: #save the new account account_name = 'Account1' client = XBMCDropBoxClient(access_token=access_token) account_info = client.getAccountInfo() if 'display_name' in account_info: account_name = path_from(account_info['display_name']) new_account = AccountSettings(account_name) new_account.access_token = access_token new_account.save() #Notify the DropboxSynchronizer NotifySyncClient().account_added_removed() #notify the user the account is added dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30004), account_name) #return to where we were and refresh xbmc.executebuiltin('container.Refresh()') elif action == 'remove': #remove the selected account account_name = urllib.unquote(params.get('account', '')) account_settings = login.get_account(account_name) if account_settings: dialog = xbmcgui.Dialog() #'are you sure' dialog if dialog.yesno(ADDON_NAME, LANGUAGE_STRING(30045), account_name) == True: try: account_settings.remove() except Exception as exc: log_error("Failed to remove the account: %s" % (str(exc))) else: #Notify the DropboxSynchronizer NotifySyncClient().account_added_removed() else: log_error("Failed to remove the account!") dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30203)) #return to where we were and refresh xbmc.executebuiltin('container.Refresh()') elif action == 'change_passcode': account_name = urllib.unquote(params.get('account', '')) account_settings = login.get_account(account_name) if account_settings: change_passcode(account_settings) #return to where we were xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False) elif action == 'change_synchronization': account_name = urllib.unquote(params.get('account', '')) account_settings = login.get_account(account_name) if account_settings: change_synchronization(account_settings) #return to where we were xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False) else: browser = AccountBrowser(params) browser.buildList() browser.show()
def run(params): # This is the entrypoint action = params.get('action', '') if action == 'add': #add an account access_token = login.getAccessToken() if access_token: #save the new account account_name = 'Account1' client = XBMCDropBoxClient(access_token=access_token) account_info = client.getAccountInfo() if 'display_name' in account_info: account_name = path_from(account_info['display_name']) new_account = AccountSettings(account_name) new_account.access_token = access_token new_account.save() #Notify the DropboxSynchronizer NotifySyncClient().account_added_removed() #notify the user the account is added dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30004), account_name) #return to where we were and refresh xbmc.executebuiltin('container.Refresh()') elif action == 'remove': #remove the selected account account_name = urllib.unquote( params.get('account', '') ) account_settings = login.get_account(account_name) if account_settings: dialog = xbmcgui.Dialog() #'are you sure' dialog if dialog.yesno(ADDON_NAME, LANGUAGE_STRING(30045), account_name ) == True: try: account_settings.remove() except Exception as exc: log_error("Failed to remove the account: %s" % (str(exc)) ) else: #Notify the DropboxSynchronizer NotifySyncClient().account_added_removed() else: log_error("Failed to remove the account!") dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30203)) #return to where we were and refresh xbmc.executebuiltin('container.Refresh()') elif action == 'change_passcode': account_name = urllib.unquote( params.get('account', '') ) account_settings = login.get_account(account_name) if account_settings: change_passcode(account_settings) #return to where we were xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False) elif action == 'change_synchronization': account_name = urllib.unquote( params.get('account', '') ) account_settings = login.get_account(account_name) if account_settings: change_synchronization(account_settings) #return to where we were xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False) else: browser = AccountBrowser(params) browser.buildList() browser.show()
#Loading more media items requested... path = sys.argv[0] + sys.argv[2] #xbmc.executebuiltin('container.update(%s, replace)'%path) # don't use replace because that removes the content_type from the path... xbmc.executebuiltin('container.update(%s)'%path) elif 'module' in params: # plugin (module) to run path = sys.argv[0] + sys.argv[2] xbmc.executebuiltin('container.update(%s)'%path) else: if 'module' in params: # Module chosen, load and execute module module = params['module'] __import__(module) current_module = sys.modules[module] current_module.run(params) elif 'action' in params and params['action'] == 'play': account_name = urllib.unquote( params.get('account', '') ).decode("utf-8") account_settings = login.get_account(account_name) if account_settings: client = XBMCDropBoxClient(access_token=account_settings.access_token) item = urllib.unquote( urllib.unquote( params['path'] ) ).decode("utf-8") url = client.getMediaUrl(item) log_debug('MediaUrl: %s'%url) listItem = xbmcgui.ListItem(item) listItem.select(True) listItem.setPath(url) xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=listItem) else: log_error("Action play: no account name provided!") xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False) else: # No module chosen #Run the browse_folder module module = 'browse_account'