#!/usr/bin/env python3 # reads SteamIDs from ./accounts.txt and outputs ban information into ./output.html import urllib.request import json import time steamapikey = "" # read file and remove trailing newline because we're making a list account_lines = [line.rstrip("\n") for line in open("accounts.txt").readlines()] ids = [] for line in account_lines: # https://developer.valvesoftware.com/wiki/SteamID Z = int(line.split(':')[2]) V = 0x0110000100000000 # profile ID constant Y = int(line.split(':')[1]) W = Z * 2 + V + Y ids.append(str(W)) # API takes in comma seperated steamids ids_string = ",".join([x for x in ids]) # https://developer.valvesoftware.com/wiki/Steam_Web_API summaries = json.load(urllib.request.urlopen("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + steamapikey + "&steamids=" + ids_string)) bans = json.load(urllib.request.urlopen("http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=" + steamapikey + "&steamids=" + ids_string)) output_file = open("output.html", "w", encoding="utf-8") output_file.write('\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ ') numbanned = 0 for i in range(len(ids)): try: for summary in summaries['response']['players']: if summary['steamid'] == str(ids[i]): break except: continue try: for ban in bans['players']: if ban['SteamId'] == str(ids[i]): break except: continue status = "" bantype = "" bandays = "" if ban['VACBanned']: status = "Pwned" bantype = "VAC" bandays = str(ban['DaysSinceLastBan']) numbanned += 1 if ban['NumberOfGameBans'] > 0: status = "Pwned" bantype = "Gameban" bandays = str(ban['DaysSinceLastBan']) numbanned += 1 name = summary['personaname'] name = name.replace("<", "<") # escape html tag names name = name.replace(">", ">") logdays = str(int((time.time() - summary['lastlogoff']) / 86400)) # length of a day in epoch line_start = ' \n') output_file.write(line_start + '' + str(ids[i]) + '\n') output_file.write(line_start + name + '\n') output_file.write(line_start + status + '\n') output_file.write(line_start + bantype + '\n') output_file.write(line_start + bandays + '\n') output_file.write(line_start + logdays + '\n') output_file.write(line_start + '"+ '\n') output_file.write(' \n') i += 1 output_file.write('\
IDNameStatusTypeBanDaysLogDaysProfile
' if status != "Pwned" else ' ' output_file.write('
\n\ ' + str(numbanned) + '/' + str(len(ids)) + ' banned\n\ \n\ \ \n')