Added Steam Names

This commit is contained in:
Philipp Glaser 2022-03-07 13:56:50 +01:00
parent c86f17317e
commit afc7c4123a
2 changed files with 19 additions and 23 deletions

View File

@ -1,6 +1,8 @@
import re import re
import requests import requests
import json import json
import xml
import xmltodict
#Steamid converter #Steamid converter
@ -17,28 +19,21 @@ def steamid_to_64bit(steamid):
#Kinda disgusting with the fixed lines and really easy to break. #Kinda disgusting with the fixed lines and really easy to break.
# I really need to clean this up # I really need to clean this up
def get_user_input(): def get_user_input():
print("Status Screen to FaceIT ELO by HerZ ") print("Status Screen to FaceIT ELO by HerZ ")
print("https://steamcommunity.com/id/HerzGegenFame") print("https://steamcommunity.com/id/HerzGegenFame")
print() print()
print("Please paste the output from the status command and then press Enter until the program resumes") print("Please paste the output from the status command and then press Enter until the program resumes")
no_of_lines = 22 no_of_lines = 22
status_string_i = "" status_string_i = ""
for i in range(no_of_lines): for i in range(no_of_lines):
status_string_i+=input()+"\n" status_string_i+=input()+"\n"
return status_string_i return status_string_i
#Regex the SteamIDs from status #Regex the SteamIDs from status
def regex_for_steamids(input_string): def regex_for_steamids(input_string):
steamids_from_status = re.findall(r"\S*STEAM_+[0-9]+:[0-9]+:[0-9]+", input_string) steamids_from_status = re.findall(r"\S*STEAM_+[0-9]+:[0-9]+:[0-9]+", input_string)
return steamids_from_status return steamids_from_status
#Get FaceIT Data #Get FaceIT Data
def get_faceit_data(steamid_64): def get_faceit_data(steamid_64):
url = "https://open.faceit.com/data/v4/players?game=csgo&game_player_id=" + str(steamid_64) url = "https://open.faceit.com/data/v4/players?game=csgo&game_player_id=" + str(steamid_64)
@ -47,22 +42,18 @@ def get_faceit_data(steamid_64):
faceit_response_json = faceit_response.json() faceit_response_json = faceit_response.json()
return faceit_response_json return faceit_response_json
#Get Steam Data
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
status_string = get_user_input() status_string = get_user_input()
steamids = regex_for_steamids(status_string) steamids = regex_for_steamids(status_string)
#Stupid counter that counts stupid numbers #Stupid counter that counts stupid numbers
i=0 i=0
@ -72,23 +63,31 @@ for entrys in steamids:
steamid = steamids[i] steamid = steamids[i]
steamid_64 = steamid_to_64bit(steamid) steamid_64 = steamid_to_64bit(steamid)
faceit_json = get_faceit_data(steamid_64)
steam_dict = get_steam_data(steamid_64)
#Print the Output #Print the Output
print("SteamID: "+steamids[i]) print("SteamID: "+steamids[i])
print()
try:
print("Steam Name: "+ steam_dict['profile']['steamID'])
except:
print("STEAM ERROR")
try: try:
print("FaceIT Name: "+ faceit_json['nickname'],)
print("Country: "+ faceit_json['country']) print("Country: "+ faceit_json['country'])
print("ELO: "+ str(faceit_json['games']['csgo']['faceit_elo'])) print("ELO: "+ str(faceit_json['games']['csgo']['faceit_elo']))
print("Level : "+ str(faceit_json['games']['csgo']['skill_level'])) print("Level : "+ str(faceit_json['games']['csgo']['skill_level']))
print("FaceIT Name: "+ faceit_json['nickname'],)
print() print()
print("############################################################") print("############################################################")
except: except:
print('No FaceIT Account found for this Steam ID') print('No FaceIT Account found for this Steam ID')
print() print()
print("############################################################") print("############################################################")
i= i+1 i= i+1

View File

@ -18,6 +18,3 @@ players : 10 humans, 0 bots (10/10 max) (not hibernating)
# 13 12 "juice" STEAM_1:0:14734584 15:13 66 0 active 786432 # 13 12 "juice" STEAM_1:0:14734584 15:13 66 0 active 786432
# 14 13 "halfway crook" STEAM_1:1:33757872 15:13 61 0 active 786432 # 14 13 "halfway crook" STEAM_1:1:33757872 15:13 61 0 active 786432
#end #end
pa