def get_team_matches(team_id): url = "https://www.easports.com/iframe/nhl14proclubs/api/platforms/" + settings.PLATFORM + \ "/clubs/" + team_id + "/matches?match_type=gameType5&matches_returned=5" response = urllib.urlopen(url) temp = json.loads(response.read())['raw'] games = [] for game in temp: item = {} item['id'] = temp[game]['matchId'] item['time'] = time.strftime( "%d.%m.%y %H:%M", time.localtime(int(temp[game]['timestamp']))) gameservice.stats_for(temp[game], item, mongo, team_id) games.append(item) return games
def get_games(game_repository, live_repository): entries = [] for game in game_repository.get_games(): entry = {} entry['id'] = game['matchId'] entry['time'] = time.strftime( "%d.%m.%y %H:%M", time.localtime(int(game['timestamp']))) gameservice.stats_for(game, entry, game_repository) players = "" for player in gameservice.get_players(game['players'][settings.HOME_TEAM], settings.HOME_TEAM, game_repository, live_repository): players += player + ", " players = players[:-2] entry['players'] = players entries.append(entry) return entries