Fix line-endings; Increase portability; Add speedtyper.py

This commit is contained in:
olari
2019-05-26 23:05:28 +03:00
parent 661a5984a3
commit 63a1b4f501
33 changed files with 1447 additions and 1341 deletions

View File

@@ -1,137 +1,138 @@
#!/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('\
<!DOCTYPE html>\n\
<html>\n\
<head>\n\
<style>\n\
body {\n\
font-family: sans-serif;\n\
}\n\
\n\
table {\n\
color: #222;\n\
border-collapse: collapse;\n\
}\n\
\n\
tr, th, td {\n\
border: 1px solid #a2a9b1;\n\
padding: 0.2em 0.4em;\n\
}\n\
\n\
.pwned {\n\
background-color: #ffb6c1\n\
}\n\
\n\
th {\n\
background-color: #eaecf0;\n\
text-align: center;\n\
}\n\
\n\
a:hover, a:visited, a:link, a:active {\n\
text-decoration: none;\n\
}\n\
</style>\n\
</head>\n\
\n\
<body>\n\
<table>\n\
<tr>\n\
<th>ID</th>\n\
<th>Name</th>\n\
<th>Status</th>\n\
<th>Type</th>\n\
<th>BanDays</th>\n\
<th>LogDays</th>\n\
<th>Profile</th>\n\
</tr>\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("<", "&lt;") # escape html tag names
name = name.replace(">", "&gt;")
logdays = str(int((time.time() - summary['lastlogoff']) / 86400)) # length of a day in epoch
line_start = ' <td>' if status != "Pwned" else ' <td class="pwned">'
output_file.write(' <tr>\n')
output_file.write(line_start + '<a target="_blank" href="' + 'https://steamcommunity.com/profiles/' + str(ids[i]) + '">' + str(ids[i]) + '</a></td>\n')
output_file.write(line_start + name + '</td>\n')
output_file.write(line_start + status + '</td>\n')
output_file.write(line_start + bantype + '</td>\n')
output_file.write(line_start + bandays + '</td>\n')
output_file.write(line_start + logdays + '</td>\n')
output_file.write(line_start + '<a target="_blank" href="' + 'https://steamcommunity.com/profiles/' + str(ids[i]) + '"><img src=' + summary['avatarmedium'] + ">"+ '</img></td>\n')
output_file.write(' </tr>\n')
i += 1
output_file.write('\
</table>\n\
' + str(numbanned) + '/' + str(len(ids)) + ' banned\n\
</body>\n\
\
</html>\n')
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 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('\
<!DOCTYPE html>\n\
<html>\n\
<head>\n\
<style>\n\
body {\n\
font-family: sans-serif;\n\
}\n\
\n\
table {\n\
color: #222;\n\
border-collapse: collapse;\n\
}\n\
\n\
tr, th, td {\n\
border: 1px solid #a2a9b1;\n\
padding: 0.2em 0.4em;\n\
}\n\
\n\
.pwned {\n\
background-color: #ffb6c1\n\
}\n\
\n\
th {\n\
background-color: #eaecf0;\n\
text-align: center;\n\
}\n\
\n\
a:hover, a:visited, a:link, a:active {\n\
text-decoration: none;\n\
}\n\
</style>\n\
</head>\n\
\n\
<body>\n\
<table>\n\
<tr>\n\
<th>ID</th>\n\
<th>Name</th>\n\
<th>Status</th>\n\
<th>Type</th>\n\
<th>BanDays</th>\n\
<th>LogDays</th>\n\
<th>Profile</th>\n\
</tr>\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("<", "&lt;") # escape html tag names
name = name.replace(">", "&gt;")
logdays = str(int((time.time() - summary['lastlogoff']) / 86400)) # length of a day in epoch
line_start = ' <td>' if status != "Pwned" else ' <td class="pwned">'
output_file.write(' <tr>\n')
output_file.write(line_start + '<a target="_blank" href="' + 'https://steamcommunity.com/profiles/' + str(ids[i]) + '">' + str(ids[i]) + '</a></td>\n')
output_file.write(line_start + name + '</td>\n')
output_file.write(line_start + status + '</td>\n')
output_file.write(line_start + bantype + '</td>\n')
output_file.write(line_start + bandays + '</td>\n')
output_file.write(line_start + logdays + '</td>\n')
output_file.write(line_start + '<a target="_blank" href="' + 'https://steamcommunity.com/profiles/' + str(ids[i]) + '"><img src=' + summary['avatarmedium'] + ">"+ '</img></td>\n')
output_file.write(' </tr>\n')
i += 1
output_file.write('\
</table>\n\
' + str(numbanned) + '/' + str(len(ids)) + ' banned\n\
</body>\n\
\
</html>\n')