This commit is contained in:
Victor Fors 2022-04-05 23:26:17 +02:00
parent bf4467c300
commit 70850519ff

15
sstatus
View File

@ -3,9 +3,10 @@ import requests
import sys import sys
import textwrap import textwrap
api = 'https://api.steampowered.com/' api = 'http://api.steampowered.com/'
key = '63578AF8E85EDF1E49411D5D4E18E166' key = '63578AF8E85EDF1E49411D5D4E18E166'
uid = '76561198008294872' uid = '76561198008294872' #whiteline
#uid = '76561198111568728' #N33R
# Fetch JSON from url and run it through transform, pretty printing errors # Fetch JSON from url and run it through transform, pretty printing errors
# and the data worked on as exhaustively as possible. # and the data worked on as exhaustively as possible.
@ -17,7 +18,7 @@ def json_query(url, transform, params={}):
sys.exit(1) sys.exit(1)
try: try:
data = result.json() data = result.json()
except JSONDecodeError as err: except requests.JSONDecodeError as err:
print('Error when decoding JSON:\nFrom endpoint ' + url + ':\n' + err + '\n' + result + '\n') print('Error when decoding JSON:\nFrom endpoint ' + url + ':\n' + err + '\n' + result + '\n')
sys.exit(1) sys.exit(1)
try: try:
@ -30,18 +31,18 @@ def json_query(url, transform, params={}):
def steam_query(endpoint, transform, params={}): def steam_query(endpoint, transform, params={}):
new_params = params.copy() new_params = params.copy()
new_params['key'] = key new_params['key'] = key
json_query(api + endpoint + '/', transform, new_params) return json_query(api + endpoint + '/', transform, new_params)
def get_friend_list(): def get_friend_list():
params = { params = {
'steamid' : uid, 'steamid' : uid,
'relationship' : 'friend' 'relationship' : 'friend'
} }
return steam_query('SteamUser/GetFriendList/v0001' lambda data: [friend['steamid'] for friend in data], params) return steam_query('ISteamUser/GetFriendList/v0001', lambda data: [friend['steamid'] for friend in data['friendslist']['friends']], params)
def main(): def main():
for steamid in get_friend_list(): for friend in get_friend_list():
print(steamid) print(friend)
if __name__ == '__main__': if __name__ == '__main__':
main() main()