Ejemplo n.º 1
0
def view_player(id_):
    print(id_, request.remote_addr)
    if len(id_) != 17 or re.match(regex, id_) is None:
        r = get_vanity_to_steam_id_or_random_response(id_, current_app)
        if r is None:
            return redirect(url_for('home'))
        id_ = r['response']['steamid']
        return redirect(url_for('players.view_player', id_=id_))
    session = current_app.config['db']()
    rank = get_rank(id_)
    total_games = player_wrapper.get_total_games(session, id_)
    games, stats, favorite_car, favorite_car_pctg, names = player_stat_wrapper.get_averaged_stats(session, id_, total_games, rank, redis=current_app.config['r'])
    steam_profile = get_steam_profile_or_random_response(id_, current_app)
    user = session.query(Player).filter(Player.platformid == id_).first()
    if user is not None:
        groups = [current_app.config['groups'][i] for i in user.groups]
    else:
        groups = []
    if steam_profile is None:
        return render_template('error.html', error="Unable to find the requested profile")

    return render_with_session('player.html', session, games=games, rank=rank, profile=steam_profile, car=favorite_car,
                               favorite_car_pctg=favorite_car_pctg, stats=stats,
                               total_games=total_games, game_per_page=player_wrapper.limit,
                               id=id_, get_stat_spider_charts=PlayerStatWrapper.get_stat_spider_charts,
                               groups=groups, names=names)
Ejemplo n.º 2
0
def compare_player_redir(id_):
    print(request.form)
    other = request.form['other']
    if len(other) != 17 or re.match(regex, other) is None:
        r = get_vanity_to_steam_id_or_random_response(other, current_app)
        if r is None:
            return redirect(url_for('players.view_player', id_=id_))
        other = r['response']['steamid']
    return redirect(url_for('players.compare_player', ids=",".join([id_, other])))
Ejemplo n.º 3
0
def render_player_history(id_, page_number):
    page_number = int(page_number)
    print(re.match(regex, id_))
    if len(id_) != 17 or re.match(regex, id_) is None:
        r = get_vanity_to_steam_id_or_random_response(id_, current_app)
        if r is None:
            return redirect(url_for('home'))
        id_ = r['response']['steamid']
        return redirect(url_for('players.view_player', id_=id_))
    session = current_app.config['db']()
    games = player_wrapper.get_player_games_paginated(session, id_, page=page_number)
    return jsonify({'html': render_template('partials/player/content/match_history.html', games=games)})
Ejemplo n.º 4
0
def api_get_player(id_or_name):
    if len(id_or_name) != 17 or re.match(re.compile('\d{17}'), id_or_name) is None:
        # Treat as name
        response = get_vanity_to_steam_id_or_random_response(id_or_name, current_app)
        if response is None:
            raise CalculatedError(404, "User not found")
        steam_id = response['response']['steamid']
        return jsonify(steam_id)
    else:
        # Treat as id
        result = steam_id_to_profile(id_or_name)
        if result is None:
            raise CalculatedError(404, "User not found")
        return jsonify(id_or_name)
Ejemplo n.º 5
0
def api_get_player(id_or_name):
    if id_or_name.startswith("(bot)"):
        return jsonify(encode_bot_name(id_or_name[5:]))
    elif len(id_or_name) != 17 or re.match(re.compile('\d{17}'), id_or_name) is None:
        # Treat as name
        response = get_vanity_to_steam_id_or_random_response(id_or_name)
        if response is None:
            raise PlayerNotFound(404, "User not found")
        steam_id = response['response']['steamid']
        return jsonify(steam_id)
    else:
        # Treat as id
        result = steam_id_to_profile(id_or_name)
        if result is None:
            raise PlayerNotFound(404, "User not found")
        return jsonify(id_or_name)