diff --git a/__pycache__/main.cpython-39.pyc b/__pycache__/main.cpython-39.pyc new file mode 100644 index 0000000..5d64759 Binary files /dev/null and b/__pycache__/main.cpython-39.pyc differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..7aabb28 --- /dev/null +++ b/main.py @@ -0,0 +1,118 @@ +from turtle import st +from flask import Flask, render_template, request, redirect, url_for +import requests +import re +import json +import xml +import xmltodict + +app = Flask(__name__) + + + + +@app.route("/", methods=["POST", "GET"]) +def index(): + if request.method == "POST": + status_screen = request.form["status_screen_input"] + steamids = regex_for_steamids(status_screen) + + + steamid64_dict = {} + faceit_elo_dict = {} + faceit_level_dict = {} + steam_name_dict = {} + steam_pic_dict = {} + for steamid in steamids: + steamid64_dict[steamid] = steamid_to_64bit(steamid) + faceit_json = get_faceit_data(steamid64_dict[steamid]) + steam_dict = get_steam_data(steamid64_dict[steamid]) + steam_name_dict[steamid] = steam_dict['profile']['steamID'] + steam_pic_dict[steamid] = steam_dict['profile']['avatarFull'] + try: + faceit_elo_dict[steamid] = faceit_json['games']['csgo']['faceit_elo'] + faceit_level_dict[steamid] = faceit_json['games']['csgo']['skill_level'] + except: + faceit_elo_dict[steamid] = "No FaceIT Account found" + faceit_level_dict[steamid] = "No FaceIT Account found" + + + + + + + return render_template('steamids.html', **locals()) + else: + return render_template('index.html') + + + + + + + + +def regex_for_steamids(input_string): + steamids_from_status = re.findall(r"\S*STEAM_+[0-9]+:[0-9]+:[0-9]+", input_string) + return steamids_from_status + +def steamid_to_64bit(steamid): + steam64id = 76561197960265728 # Who tf knows how this works + # IT JUST FUCKING DOES! + id_split = steamid.split(":") + steam64id += int(id_split[2]) * 2 # JUST MULTIPLY BY 2... Cause THAT MAKES PERFEKT SENSE RIGHT?! + if id_split[1] == "1": + steam64id += 1 + return steam64id + +def get_steam_data(steamid_64): + steamurl ="https://steamcommunity.com/profiles/" + str(steamid_64) +"/?xml=1" + steam_req = requests.get(steamurl) + steamdict_funct = xmltodict.parse(steam_req.content) + return steamdict_funct + +def get_faceit_data(steamid_64): + url = "https://open.faceit.com/data/v4/players?game=csgo&game_player_id=" + str(steamid_64) + headers = { 'accept': 'application/json', 'Authorization' : 'Bearer ab46a7ab-6ab8-4c00-a8ff-41c0ff71d562' } + faceit_response = requests.get(url, headers=headers) + faceit_response_json = faceit_response.json() + return faceit_response_json + + + + + + + + + + + +if __name__ == "__main__": + app.run(host="127.0.0.1", port=8080, debug=True) + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/faceit1.svg b/static/faceit1.svg new file mode 100644 index 0000000..4e96f2c --- /dev/null +++ b/static/faceit1.svg @@ -0,0 +1 @@ + diff --git a/static/faceit10.svg b/static/faceit10.svg new file mode 100644 index 0000000..b4eac44 --- /dev/null +++ b/static/faceit10.svg @@ -0,0 +1 @@ + diff --git a/static/faceit2.svg b/static/faceit2.svg new file mode 100644 index 0000000..1b26f19 --- /dev/null +++ b/static/faceit2.svg @@ -0,0 +1 @@ + diff --git a/static/faceit3.svg b/static/faceit3.svg new file mode 100644 index 0000000..60b8ed6 --- /dev/null +++ b/static/faceit3.svg @@ -0,0 +1 @@ + diff --git a/static/faceit4.svg b/static/faceit4.svg new file mode 100644 index 0000000..807b70e --- /dev/null +++ b/static/faceit4.svg @@ -0,0 +1 @@ + diff --git a/static/faceit5.svg b/static/faceit5.svg new file mode 100644 index 0000000..c18386d --- /dev/null +++ b/static/faceit5.svg @@ -0,0 +1 @@ + diff --git a/static/faceit6.svg b/static/faceit6.svg new file mode 100644 index 0000000..77a0357 --- /dev/null +++ b/static/faceit6.svg @@ -0,0 +1 @@ + diff --git a/static/faceit7.svg b/static/faceit7.svg new file mode 100644 index 0000000..5b772b6 --- /dev/null +++ b/static/faceit7.svg @@ -0,0 +1 @@ + diff --git a/static/faceit8.svg b/static/faceit8.svg new file mode 100644 index 0000000..211ced3 --- /dev/null +++ b/static/faceit8.svg @@ -0,0 +1 @@ + diff --git a/static/faceit9.svg b/static/faceit9.svg new file mode 100644 index 0000000..6b76bb9 --- /dev/null +++ b/static/faceit9.svg @@ -0,0 +1 @@ + diff --git a/static/logo.png b/static/logo.png new file mode 100644 index 0000000..c36851f Binary files /dev/null and b/static/logo.png differ diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..98660e0 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,22 @@ + + +
+ +
+ {% if faceit_level_dict[steamid] == 1 %}
+
+ {% elif faceit_level_dict[steamid] == 2 %}
+
+ {% elif faceit_level_dict[steamid] == 3 %}
+
+ {% elif faceit_level_dict[steamid] == 4 %}
+
+ {% elif faceit_level_dict[steamid] == 5 %}
+
+ {% elif faceit_level_dict[steamid] == 6 %}
+
+ {% elif faceit_level_dict[steamid] == 7 %}
+
+ {% elif faceit_level_dict[steamid] == 8 %}
+
+ {% elif faceit_level_dict[steamid] == 9 %}
+
+ {% elif faceit_level_dict[steamid] == 10 %}
+
+ {% else %}
+
"No FaceIT Account Found.
+ {% endif %} + +