mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 05:23:12 -07:00
Make psn-account-id.py Script easier for Windows
This commit is contained in:
parent
5ddf9ef373
commit
dc11724627
1 changed files with 49 additions and 24 deletions
|
@ -6,6 +6,14 @@ if sys.version_info < (3, 0, 0):
|
||||||
print("DO NOT use Python 2.\nEVER.\nhttps://pythonclock.org")
|
print("DO NOT use Python 2.\nEVER.\nhttps://pythonclock.org")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
import platform
|
||||||
|
oldexit = exit
|
||||||
|
def exit(code):
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
import atexit
|
||||||
|
input("Press Enter to exit.")
|
||||||
|
oldexit(code)
|
||||||
|
|
||||||
if sys.stdout.encoding.lower() == "ascii":
|
if sys.stdout.encoding.lower() == "ascii":
|
||||||
import codecs
|
import codecs
|
||||||
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer)
|
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer)
|
||||||
|
@ -15,8 +23,25 @@ try:
|
||||||
import requests
|
import requests
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("\"requests\" is not available. Install it with pip whatever.")
|
if platform.system() == "Windows":
|
||||||
|
from distutils.util import strtobool
|
||||||
|
a = input("The requests module is not available. Should we try to install it automatically using pip? [y/n] ")
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
a = strtobool(a)
|
||||||
|
break
|
||||||
|
except ValueError:
|
||||||
|
a = input("Please answer with y or n: ")
|
||||||
|
if a == 1:
|
||||||
|
import subprocess
|
||||||
|
subprocess.call([sys.executable, "-m", "pip", "install", "requests"])
|
||||||
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
else:
|
||||||
|
print("\"requests\" is not available. Install it with pip or your distribution's package manager.")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
from urllib.parse import urlparse, parse_qs, quote, urljoin
|
from urllib.parse import urlparse, parse_qs, quote, urljoin
|
||||||
import pprint
|
import pprint
|
||||||
|
@ -73,8 +98,7 @@ token = token_json["access_token"]
|
||||||
|
|
||||||
print("🌏 Requesting Account Info")
|
print("🌏 Requesting Account Info")
|
||||||
|
|
||||||
account_request = requests.get(TOKEN_URL + "/" + quote(token),
|
account_request = requests.get(TOKEN_URL + "/" + quote(token), auth = api_auth)
|
||||||
auth = api_auth)
|
|
||||||
|
|
||||||
if account_request.status_code != 200:
|
if account_request.status_code != 200:
|
||||||
print("☠️ Request failed with code {}:\n{}".format(account_request.status_code, account_request.text))
|
print("☠️ Request failed with code {}:\n{}".format(account_request.status_code, account_request.text))
|
||||||
|
@ -94,4 +118,5 @@ user_id_base64 = base64.b64encode(user_id.to_bytes(8, "little")).decode()
|
||||||
print()
|
print()
|
||||||
print("🍙 This is your AccountID:")
|
print("🍙 This is your AccountID:")
|
||||||
print(user_id_base64)
|
print(user_id_base64)
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue