mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-14 10:50:13 +01:00
generate_emu_config.py fixes and improvements.
This commit is contained in:
parent
eef92f1fe6
commit
e59508a696
2 changed files with 78 additions and 24 deletions
|
@ -3,22 +3,28 @@ USERNAME = ""
|
|||
PASSWORD = ""
|
||||
|
||||
#steam ids with public profiles that own a lot of games
|
||||
TOP_OWNER_IDS = [76561198028121353, 76561198001237877, 76561198001678750, 76561198237402290]
|
||||
TOP_OWNER_IDS = [76561198028121353, 76561198001237877, 76561198355625888, 76561198001678750, 76561198237402290]
|
||||
|
||||
from stats_schema_achievement_gen import achievements_gen
|
||||
from steam.client import SteamClient
|
||||
from steam.client.cdn import CDNClient
|
||||
from steam.enums import common
|
||||
from steam.enums.common import EResult
|
||||
from steam.enums.emsg import EMsg
|
||||
from steam.core.msg import MsgProto
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
prompt_for_unavailable = True
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("\nUsage: {} appid\n\nExample: {} 480\n".format(sys.argv[0], sys.argv[0]))
|
||||
print("\nUsage: {} appid appid appid etc..\n\nExample: {} 480\n".format(sys.argv[0], sys.argv[0]))
|
||||
exit(1)
|
||||
|
||||
appid = int(sys.argv[1])
|
||||
appids = []
|
||||
for id in sys.argv[1:]:
|
||||
appids += [int(id)]
|
||||
|
||||
client = SteamClient()
|
||||
if not os.path.exists("login_temp"):
|
||||
|
@ -28,16 +34,40 @@ client.set_credential_location("login_temp")
|
|||
if (len(USERNAME) == 0 or len(PASSWORD) == 0):
|
||||
client.cli_login()
|
||||
else:
|
||||
while True:
|
||||
ret = client.login(USERNAME, password=PASSWORD)
|
||||
if ret != common.EResult.OK:
|
||||
if ret == common.EResult.TryAnotherCM:
|
||||
continue
|
||||
print("error logging in with set username and password, trying cli login. error was:", ret)
|
||||
client.cli_login()
|
||||
break
|
||||
else:
|
||||
break
|
||||
result = client.login(USERNAME, password=PASSWORD)
|
||||
while result in (EResult.AccountLogonDenied, EResult.InvalidLoginAuthCode,
|
||||
EResult.AccountLoginDeniedNeedTwoFactor, EResult.TwoFactorCodeMismatch,
|
||||
EResult.TryAnotherCM, EResult.ServiceUnavailable,
|
||||
EResult.InvalidPassword,
|
||||
):
|
||||
|
||||
if result == EResult.InvalidPassword:
|
||||
print("invalid password, the password you set is wrong.")
|
||||
exit(1)
|
||||
|
||||
elif result in (EResult.AccountLogonDenied, EResult.InvalidLoginAuthCode):
|
||||
prompt = ("Enter email code: " if result == EResult.AccountLogonDenied else
|
||||
"Incorrect code. Enter email code: ")
|
||||
auth_code, two_factor_code = input(prompt), None
|
||||
|
||||
elif result in (EResult.AccountLoginDeniedNeedTwoFactor, EResult.TwoFactorCodeMismatch):
|
||||
prompt = ("Enter 2FA code: " if result == EResult.AccountLoginDeniedNeedTwoFactor else
|
||||
"Incorrect code. Enter 2FA code: ")
|
||||
auth_code, two_factor_code = None, input(prompt)
|
||||
|
||||
elif result in (EResult.TryAnotherCM, EResult.ServiceUnavailable):
|
||||
if prompt_for_unavailable and result == EResult.ServiceUnavailable:
|
||||
while True:
|
||||
answer = input("Steam is down. Keep retrying? [y/n]: ").lower()
|
||||
if answer in 'yn': break
|
||||
|
||||
prompt_for_unavailable = False
|
||||
if answer == 'n': break
|
||||
|
||||
client.reconnect(maxdelay=15)
|
||||
|
||||
result = client.login(USERNAME, PASSWORD, None, auth_code, two_factor_code)
|
||||
|
||||
|
||||
def get_stats_schema(client, game_id, owner_id):
|
||||
message = MsgProto(EMsg.ClientGetUserStats)
|
||||
|
@ -49,27 +79,50 @@ def get_stats_schema(client, game_id, owner_id):
|
|||
client.send(message)
|
||||
return client.wait_msg(EMsg.ClientGetUserStatsResponse, timeout=5)
|
||||
|
||||
def generate_achievement_stats(client, game_id, output_directory):
|
||||
def generate_achievement_stats(client, game_id, output_directory, backup_directory):
|
||||
steam_id_list = TOP_OWNER_IDS + [client.steam_id]
|
||||
for x in steam_id_list:
|
||||
out = get_stats_schema(client, game_id, x)
|
||||
if out is not None:
|
||||
if len(out.body.schema) > 0:
|
||||
with open('UserGameStatsSchema_{}.bin'.format(appid), 'wb') as f:
|
||||
with open(os.path.join(backup_directory, 'UserGameStatsSchema_{}.bin'.format(appid)), 'wb') as f:
|
||||
f.write(out.body.schema)
|
||||
achievements, stats = achievements_gen.generate_stats_achievements(out.body.schema, output_directory)
|
||||
return
|
||||
else:
|
||||
print("no schema", out)
|
||||
|
||||
out_dir = os.path.join("{}".format( "{}_output".format(appid)), "steam_settings")
|
||||
for appid in appids:
|
||||
backup_dir = os.path.join("backup","{}".format(appid))
|
||||
out_dir = os.path.join("{}".format( "{}_output".format(appid)), "steam_settings")
|
||||
|
||||
if not os.path.exists(out_dir):
|
||||
os.makedirs(out_dir)
|
||||
if not os.path.exists(backup_dir):
|
||||
os.makedirs(backup_dir)
|
||||
|
||||
print("outputting config to", out_dir)
|
||||
if not os.path.exists(out_dir):
|
||||
os.makedirs(out_dir)
|
||||
|
||||
generate_achievement_stats(client, appid, out_dir)
|
||||
with open(os.path.join(out_dir, "steam_appid.txt"), 'w') as f:
|
||||
f.write(str(appid))
|
||||
print("outputting config to", out_dir)
|
||||
|
||||
raw = client.get_product_info(apps=[appid])
|
||||
game_info = raw["apps"][appid]
|
||||
|
||||
if "common" in game_info:
|
||||
game_info_common = game_info["common"]
|
||||
if "community_visible_stats" in game_info_common:
|
||||
generate_achievement_stats(client, appid, out_dir, backup_dir)
|
||||
|
||||
with open(os.path.join(out_dir, "steam_appid.txt"), 'w') as f:
|
||||
f.write(str(appid))
|
||||
|
||||
if "depots" in game_info:
|
||||
if "branches" in game_info["depots"]:
|
||||
if "public" in game_info["depots"]["branches"]:
|
||||
if "buildid" in game_info["depots"]["branches"]["public"]:
|
||||
buildid = game_info["depots"]["branches"]["public"]["buildid"]
|
||||
with open(os.path.join(out_dir, "build_id.txt"), 'w') as f:
|
||||
f.write(str(buildid))
|
||||
|
||||
game_info_backup = json.dumps(game_info, indent=4)
|
||||
with open(os.path.join(backup_dir, "product_info.json"), "w") as f:
|
||||
f.write(game_info_backup)
|
||||
|
|
|
@ -4,10 +4,11 @@ This script depends on python files that are in subfolders so make sure to downl
|
|||
|
||||
Using the script: python generate_emu_config.py appid
|
||||
|
||||
You can also pass multiple appids to generate multiple configs: python generate_emu_config.py appid appid appid
|
||||
|
||||
The appid is the number in the steam url.
|
||||
|
||||
The first time you run the script it will ask you for your steam username, password and email code.
|
||||
The email code will only be asked the first time and the sentry will be saved to the login_temp folder.
|
||||
The email code should only be asked the first time and the sentry will be saved to the login_temp folder.
|
||||
|
||||
This script will not save your username/password anywhere. If you don't want to always type it you must
|
||||
open up the script in a text editor and change:
|
||||
|
|
Loading…
Reference in a new issue