-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
33 lines (27 loc) · 968 Bytes
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from pypresence import Client
import requests
import json
import os
client_id = "696685746832277534"
def setup():
client = Client(client_id)
client.start()
auth = client.authorize(client_id, ['rpc'])
client.close()
rpcToken = auth["data"]["code"]
if rpcToken != None:
headers = {
"rpcToken": rpcToken,
}
user_object = requests.get("https://rich-presence-api.glitch.me/setup", headers=headers)
if user_object.status_code == 200:
user_json = user_object.json()
with open(os.path.abspath(os.getcwd()) + '\data.json','w') as outfile:
json.dump(user_json, outfile)
return user_json
else:
raise RuntimeWarning("One or more of the apis errored.")
else:
raise RuntimeWarning("Error when obtaining RPC token.")
if __name__ == "__main__":
setup()