From afc7c4123a6a3e3b44d306788990fb500e69be90 Mon Sep 17 00:00:00 2001 From: Philipp Glaser Date: Mon, 7 Mar 2022 13:56:50 +0100 Subject: [PATCH] Added Steam Names --- EloFinder-by-HerZ.py | 39 +++++++++++++++++++-------------------- test status.txt | 3 --- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/EloFinder-by-HerZ.py b/EloFinder-by-HerZ.py index a56c9d6..f86e703 100644 --- a/EloFinder-by-HerZ.py +++ b/EloFinder-by-HerZ.py @@ -1,6 +1,8 @@ import re import requests import json +import xml +import xmltodict #Steamid converter @@ -17,28 +19,21 @@ def steamid_to_64bit(steamid): #Kinda disgusting with the fixed lines and really easy to break. # I really need to clean this up def get_user_input(): - 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") - no_of_lines = 22 status_string_i = "" for i in range(no_of_lines): status_string_i+=input()+"\n" return status_string_i - - #Regex the SteamIDs from status 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 - - - #Get FaceIT Data def get_faceit_data(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() 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() - steamids = regex_for_steamids(status_string) - - - #Stupid counter that counts stupid numbers i=0 @@ -72,23 +63,31 @@ for entrys in steamids: steamid = steamids[i] steamid_64 = steamid_to_64bit(steamid) + faceit_json = get_faceit_data(steamid_64) + steam_dict = get_steam_data(steamid_64) #Print the Output print("SteamID: "+steamids[i]) + print() + + try: + print("Steam Name: "+ steam_dict['profile']['steamID']) + except: + print("STEAM ERROR") + try: - print("FaceIT Name: "+ faceit_json['nickname'],) print("Country: "+ faceit_json['country']) print("ELO: "+ str(faceit_json['games']['csgo']['faceit_elo'])) print("Level : "+ str(faceit_json['games']['csgo']['skill_level'])) + print("FaceIT Name: "+ faceit_json['nickname'],) print() print("############################################################") - except: print('No FaceIT Account found for this Steam ID') print() print("############################################################") - + i= i+1 diff --git a/test status.txt b/test status.txt index 6d803f5..89da2a3 100644 --- a/test status.txt +++ b/test status.txt @@ -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 # 14 13 "halfway crook" STEAM_1:1:33757872 15:13 61 0 active 786432 #end - - -pa \ No newline at end of file