def Teams(self, team=None, sport=None, country=None, league=None): teamlist = [] if team or sport or country or league: if team and not sport and not country and not league: url = '%s/%s/searchteams.php?t=%s' % ( API_BASE_URL, API_KEY, urllib.quote(team)) elif not team and league and not sport and not country: url = '%s/%s/search_all_teams.php?l=%s' % ( API_BASE_URL, API_KEY, urllib.quote(league)) elif not team and not league and sport and country: url = '%s/%s/search_all_teams.php?s=%s&c=%s' % ( API_BASE_URL, API_KEY, urllib.quote(sport), urllib.quote(country)) else: url = None if url: data = json.load(urllib2.urlopen(url)) teams = data["teams"] if teams: for tm in teams: teamlist.append(_team.as_team(tm)) else: xbmc.log(msg="[TheSportsDB] Invalid Parameters", level=xbmc.LOGERROR) else: xbmc.log( msg= "[TheSportsDB] team,sport,country or league must be provided", level=xbmc.LOGERROR) return teamlist
def Teams(self, team=None, sport=None, country=None, league=None): teamlist = [] if team or sport or country or league: if team and not sport and not country and not league: url = "%s/%s/searchteams.php?t=%s" % (API_BASE_URL, API_KEY, urllib.quote(team)) elif not team and league and not sport and not country: url = "%s/%s/search_all_teams.php?l=%s" % (API_BASE_URL, API_KEY, urllib.quote(league)) elif not team and not league and sport and country: url = "%s/%s/search_all_teams.php?s=%s&c=%s" % ( API_BASE_URL, API_KEY, urllib.quote(sport), urllib.quote(country), ) else: url = None if url: data = json.load(urllib2.urlopen(url)) teams = data["teams"] if teams: for tm in teams: teamlist.append(_team.as_team(tm)) else: xbmc.log(msg="[TheSportsDB] Invalid Parameters", level=xbmc.LOGERROR) else: xbmc.log(msg="[TheSportsDB] team,sport,country or league must be provided", level=xbmc.LOGERROR) return teamlist
def Team(self, teamid=None, leagueid=None): teamlist = [] if teamid or leagueid: if teamid and not leagueid: url = "%s/%s/lookupteam.php?id=%s" % (API_BASE_URL, API_KEY, str(teamid)) elif leagueid and not teamid: url = "%s/%s/lookup_all_teams.php?id=%s" % (API_BASE_URL, API_KEY, str(leagueid)) else: xbmc.log(msg="[TheSportsDB] Invalid parameters", level=xbmc.LOGERROR) return teamlist data = json.load(urllib2.urlopen(url)) teams = data["teams"] if teams: for tm in teams: teamlist.append(_team.as_team(tm)) else: xbmc.log(msg="[TheSportsDB] teamid or leagueid must be provided", level=xbmc.LOGERROR) return teamlist
def Team(self, teamid=None, leagueid=None): teamlist = [] if teamid or leagueid: if teamid and not leagueid: url = '%s/%s/lookupteam.php?id=%s' % (API_BASE_URL, API_KEY, str(teamid)) elif leagueid and not teamid: url = '%s/%s/lookup_all_teams.php?id=%s' % ( API_BASE_URL, API_KEY, str(leagueid)) else: xbmc.log(msg="[TheSportsDB] Invalid parameters", level=xbmc.LOGERROR) return teamlist data = json.load(urllib2.urlopen(url)) teams = data["teams"] if teams: for tm in teams: teamlist.append(_team.as_team(tm)) else: xbmc.log( msg="[TheSportsDB] teamid or leagueid must be provided", level=xbmc.LOGERROR) return teamlist