faceitfinder/Status_to_FaceIT_Stats.py

107 lines
3.0 KiB
Python

import re
import requests
import json
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
print(" /|_")
print(" ........ / |_ ........")
print(" .........../ /............")
print(" ............/ >..............")
print(" .............( >................")
print(" ............./ /..................")
print("............./ /.....................")
print("............/ /.....................")
print(".........__/ \_____.................")
print(" ......./' |................")
print(" ......./ /-\ /...............")
print(" ...../ / \--/................")
print(" .../ /.......................")
print(" / /.....................")
print(" ( >....................")
print(" / >...................")
print(" / _| .................")
print(" / __/ .............")
print(" /_/ .........")
print(" .....")
print(" ...")
print(" .")
print()
print()
print("Status Screen to FaceIT ELO by HerZ ")
print("https://steamcommunity.com/id/HerzGegenFame")
print()
print("Please paste the output from the status command and then press Enter until the program resumes")
print()
#Input of Status screen.
#Kinda disgusting with the fixed lines and really easy to break.
# I really need to clean this up
no_of_lines = 22
lines = ""
for i in range(no_of_lines):
lines+=input()+"\n"
#Debug leftovers
#print(lines)
#Regex the SteamIDs from status
steamids = re.findall(r"\S*STEAM_+[0-9]+:[0-9]+:[0-9]+", lines)
#Stupid counter that counts stupid numbers
i=0
#Loop over all the IDs
for entrys in steamids:
#Converet IDS
steamid = steamids[i]
steamid_64 = steamid_to_64bit(steamid)
#Get FaceIT Data
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' }
r = requests.get(url, headers=headers)
rjson = r.json()
#Print the Output
print("SteamID: "+steamids[i])
try:
print("FaceIT Name: "+ rjson['nickname'],)
print("Country: "+ rjson['country'])
print("ELO: "+ str(rjson['games']['csgo']['faceit_elo']))
print("Level : "+ str(rjson['games']['csgo']['skill_level']))
print()
print("############################################################")
except:
print('No FaceIT Account found for this Steam ID')
print()
print("############################################################")
i= i+1
input('Press ENTER to exit')