Add anonymous mode, use argparser

merge-requests/51/head
Timic 2023-05-23 18:45:55 +02:00
parent 475342f0d8
commit 70c2a92a9e
1 changed files with 43 additions and 35 deletions

View File

@ -13,6 +13,7 @@ from steam.enums import common
from steam.enums.common import EResult from steam.enums.common import EResult
from steam.enums.emsg import EMsg from steam.enums.emsg import EMsg
from steam.core.msg import MsgProto from steam.core.msg import MsgProto
import argparse
import os import os
import sys import sys
import json import json
@ -23,22 +24,29 @@ import queue
prompt_for_unavailable = True prompt_for_unavailable = True
if len(sys.argv) < 2: parser = argparse.ArgumentParser(
print("\nUsage: {} appid appid appid etc..\n\nExample: {} 480\n".format(sys.argv[0], sys.argv[0])) prog="GenerateEmuConfig",
exit(1) description="Emulator Config Generator"
)
appids = [] parser.add_argument("app_id", nargs="+", help="Steam application IDs")
for id in sys.argv[1:]: parser.add_argument("-a", "--anonymous", action="store_true", help="Enable anonymous login mode")
appids += [int(id)]
args = parser.parse_args()
appids = [int(id) for id in args.app_id]
client = SteamClient() client = SteamClient()
if not os.path.exists("login_temp"): if not os.path.exists("login_temp"):
os.makedirs("login_temp") os.makedirs("login_temp")
client.set_credential_location("login_temp") client.set_credential_location("login_temp")
if (len(USERNAME) == 0 or len(PASSWORD) == 0): if args.anonymous:
client.cli_login() client.anonymous_login()
else: else:
if (len(USERNAME) == 0 or len(PASSWORD) == 0):
client.cli_login()
else:
result = client.login(USERNAME, password=PASSWORD) result = client.login(USERNAME, password=PASSWORD)
auth_code, two_factor_code = None, None auth_code, two_factor_code = None, None
while result in (EResult.AccountLogonDenied, EResult.InvalidLoginAuthCode, while result in (EResult.AccountLogonDenied, EResult.InvalidLoginAuthCode,