def Player(self, playerid=None, teamid=None): playerlist = [] if playerid or teamid: if playerid and not teamid: url = '%s/%s/lookupplayer.php?id=%s' % ( API_BASE_URL, API_KEY, str(playerid)) key = "players" elif teamid and not playerid: url = '%s/%s/lookup_all_players.php?id=%s' % ( API_BASE_URL, API_KEY, str(teamid)) key = "player" else: xbmc.log(msg="[TheSportsDB] Invalid parameters", level=xbmc.LOGERROR) return playerlist data = json.load(urllib2.urlopen(url)) players = data[key] if players: for pl in players: playerlist.append(_player.as_player(pl)) else: xbmc.log( msg="[TheSportsDB] playerid or teamid must be provided", level=xbmc.LOGERROR) return playerlist
def Player(self, playerid=None, teamid=None): playerlist = [] if playerid or teamid: if playerid and not teamid: url = "%s/%s/lookupplayer.php?id=%s" % (API_BASE_URL, API_KEY, str(playerid)) key = "players" elif teamid and not playerid: url = "%s/%s/lookup_all_players.php?id=%s" % (API_BASE_URL, API_KEY, str(teamid)) key = "player" else: xbmc.log(msg="[TheSportsDB] Invalid parameters", level=xbmc.LOGERROR) return playerlist data = json.load(urllib2.urlopen(url)) players = data[key] if players: for pl in players: playerlist.append(_player.as_player(pl)) else: xbmc.log(msg="[TheSportsDB] playerid or teamid must be provided", level=xbmc.LOGERROR) return playerlist
def Players(self, team=None, player=None): playerlist = [] if team or player: if team and not player: url = '%s/%s/searchplayers.php?t=%s' % ( API_BASE_URL, API_KEY, urllib.quote(team)) elif not team and player: url = '%s/%s/searchplayers.php?p=%s' % ( API_BASE_URL, API_KEY, urllib.quote(player)) else: url = '%s/%s/searchplayers.php?t=%s&p=%s' % ( API_BASE_URL, API_KEY, urllib.quote(team), urllib.quote(player)) data = json.load(urllib2.urlopen(url)) players = data["player"] if players: for pl in players: playerlist.append(_player.as_player(pl)) else: xbmc.log(msg="[TheSportsDB] team or player must be provided", level=xbmc.LOGERROR) return playerlist
def Players(self, team=None, player=None): playerlist = [] if team or player: if team and not player: url = "%s/%s/searchplayers.php?t=%s" % (API_BASE_URL, API_KEY, urllib.quote(team)) elif not team and player: url = "%s/%s/searchplayers.php?p=%s" % (API_BASE_URL, API_KEY, urllib.quote(player)) else: url = "%s/%s/searchplayers.php?t=%s&p=%s" % ( API_BASE_URL, API_KEY, urllib.quote(team), urllib.quote(player), ) data = json.load(urllib2.urlopen(url)) players = data["player"] if players: for pl in players: playerlist.append(_player.as_player(pl)) else: xbmc.log(msg="[TheSportsDB] team or player must be provided", level=xbmc.LOGERROR) return playerlist