url = urllib.unquote_plus(params.get(PARAMETER_KEY_URL, "")) name = urllib.unquote_plus(params.get("name", "")) mode = int(params.get(PARAMETER_KEY_MODE, "0")) nexturl = params.get("nexturl", "") query = urllib.unquote_plus(params.get("q", "")) oauth_token = urllib.unquote_plus(params.get(PARAMETER_KEY_TOKEN, "")) handle = int(sys.argv[1]) username = xbmcplugin.getSetting(handle, SETTING_USERNAME) password = xbmcplugin.getSetting(handle, SETTING_PASSWORD) login = xbmcplugin.getSetting(handle, SETTING_LOGIN) if login == "true" and (not username or not password): xbmcaddon.Addon(id=PLUGIN_ID).openSettings() soundcloud_client = SoundCloudClient(login, username, password, oauth_token) if oauth_token == "": oauth_token = soundcloud_client.oauth_token if login == "true" and oauth_token == "": #error login failed login = "******" loginerror = "true" common.log("Login Failed", 2) def addDirectoryItem(name, label2='', infoType="Music", infoLabels={},
url = urllib.unquote_plus(params.get(PARAMETER_KEY_URL, "")) name = urllib.unquote_plus(params.get("name", "")) mode = int(params.get(PARAMETER_KEY_MODE, "0")) nexturl = params.get("nexturl","") query = urllib.unquote_plus(params.get("q", "")) oauth_token = urllib.unquote_plus(params.get(PARAMETER_KEY_TOKEN,"")) handle = int(sys.argv[1]) username = xbmcplugin.getSetting(handle, SETTING_USERNAME) password = xbmcplugin.getSetting(handle, SETTING_PASSWORD) login = xbmcplugin.getSetting(handle, SETTING_LOGIN) if login=="true" and (not username or not password): xbmcaddon.Addon(id=PLUGIN_ID).openSettings() soundcloud_client = SoundCloudClient(login, username, password, oauth_token) if oauth_token=="": oauth_token = soundcloud_client.oauth_token if login=="true" and oauth_token=="": #error login failed login="******" loginerror="true" common.log("Login Failed", 2) def addDirectoryItem(name, label2='', infoType="Music", infoLabels={}, isFolder=True, parameters={}, url=""): ''' Add a list item to the XBMC UI.''' li = xbmcgui.ListItem(name, label2) if not infoLabels:
MODE_USERS = 20 MODE_USERS_MENU = 21 MODE_USERS_FAVORITES = 22 MODE_USERS_SEARCH = 23 MODE_USERS_HOTTEST = 24 MODE_USERS_TRACKS = 25 # Parameter keys PARAMETER_KEY_OFFSET = u'offset' PARAMETER_KEY_LIMIT = u'limit' PARAMETER_KEY_MODE = u'mode' PARAMETER_KEY_URL = u'url' PARAMETER_KEY_PERMALINK = u'permalink' handle = int(sys.argv[1]) soundcloud_client = SoundCloudClient() def addDirectoryItem(name, label2='', infoType="Music", infoLabels={}, isFolder=True, parameters={}): ''' Add a list item to the XBMC UI.''' li = xbmcgui.ListItem(name, label2) if not infoLabels: infoLabels = {"Title": name } li.setInfo(infoType, infoLabels) url = sys.argv[0] + '?' + urllib.urlencode(parameters) return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=li, isFolder=isFolder) def show_tracks_menu(): ''' Show the Tracks menu. ''' addDirectoryItem(name="Hottest", parameters={PARAMETER_KEY_URL: PLUGIN_URL + "tracks/hottest", PARAMETER_KEY_MODE: MODE_TRACKS_HOTTEST}, isFolder=True) addDirectoryItem(name="Search", parameters={PARAMETER_KEY_URL: PLUGIN_URL + "tracks/search", PARAMETER_KEY_MODE: MODE_TRACKS_SEARCH}, isFolder=True)