mirror of
https://github.com/zoffline/zwift-offline.git
synced 2025-12-05 20:40:03 -08:00
Download economy config
This commit is contained in:
@@ -220,7 +220,7 @@ To obtain your current profile:
|
||||
* Ensure zoffline is disabled.
|
||||
* Run ``scripts/get_profile.py -u <your_zwift_username>``
|
||||
* Or, if using the Windows zoffline.exe version without Python installed you can run ``get_profile.exe`` obtained from https://github.com/zoffline/zwift-offline/releases/tag/zoffline_helper in place of ``scripts/get_profile.py``
|
||||
* Move the resulting ``profile.bin`` and ``achievements.bin`` (saved in whatever directory you ran get_profile.py in) into the ``storage/1`` directory.
|
||||
* Move the resulting ``profile.bin``, ``achievements.bin`` and ``economy_config.txt`` (saved in whatever directory you ran get_profile.py in) into the ``storage/1`` directory.
|
||||
* If using zoffline.exe on Windows, create a ``storage/1`` directory within the same folder as zoffline.exe if it does not already exist.
|
||||
* If using Docker, the directory ``1`` should be in the path you passed to ``-v``
|
||||
|
||||
|
||||
@@ -87,6 +87,28 @@ def query(session, access_token, route):
|
||||
print('HTTP Request failed: %s' % e)
|
||||
|
||||
|
||||
def api_login(session, access_token, login_request):
|
||||
try:
|
||||
response = session.post(
|
||||
url="https://us-or-rly101.zwift.com/api/users/login",
|
||||
headers={
|
||||
"Content-Type": "application/x-protobuf-lite",
|
||||
"Accept": "application/x-protobuf-lite",
|
||||
"Connection": "keep-alive",
|
||||
"Host": "us-or-rly101.zwift.com",
|
||||
"User-Agent": "Zwift/115 CFNetwork/758.0.2 Darwin/15.0.0",
|
||||
"Authorization": "Bearer %s" % access_token,
|
||||
"Accept-Language": "en-us",
|
||||
},
|
||||
data=login_request.SerializeToString(),
|
||||
)
|
||||
|
||||
return response.content
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print('HTTP Request failed: %s' % e)
|
||||
|
||||
|
||||
def logout(session, refresh_token):
|
||||
# Logout
|
||||
# POST https://secure.zwift.com/auth/realms/zwift/tokens/logout
|
||||
|
||||
@@ -11,7 +11,7 @@ message LoginResponse {
|
||||
}
|
||||
|
||||
message LoginRequest {
|
||||
required AnalyticsEventProperties properties = 1;
|
||||
optional AnalyticsEventProperties properties = 1;
|
||||
required bytes key = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()
|
||||
import per_session_info_pb2 as per__session__info__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0blogin.proto\x1a\x16per-session-info.proto\"\x9b\x01\n\rLoginResponse\x12\x15\n\rsession_state\x18\x01 \x02(\t\x12\x1d\n\x04info\x18\x02 \x02(\x0b\x32\x0f.PerSessionInfo\x12\x18\n\x10relay_session_id\x18\x03 \x01(\r\x12\x12\n\nexpiration\x18\x04 \x01(\r\x12&\n\x0e\x65\x63onomy_config\x18\x05 \x01(\x0b\x32\x0e.EconomyConfig\"J\n\x0cLoginRequest\x12-\n\nproperties\x18\x01 \x02(\x0b\x32\x19.AnalyticsEventProperties\x12\x0b\n\x03key\x18\x02 \x02(\x0c\"0\n\x16\x41nalyticsEventProperty\x12\n\n\x02\x66\x31\x18\x01 \x02(\t\x12\n\n\x02\x66\x32\x18\x02 \x02(\t\"E\n\x18\x41nalyticsEventProperties\x12)\n\x08property\x18\x02 \x03(\x0b\x32\x17.AnalyticsEventProperty\"K\n\x1bRelaySessionRefreshResponse\x12\x18\n\x10relay_session_id\x18\x01 \x02(\r\x12\x12\n\nexpiration\x18\x02 \x02(\r\"\xa5\x01\n\rEconomyConfig\x12\x1e\n\x0e\x63ycling_levels\x18\x01 \x03(\x0b\x32\x06.Level\x12\x1e\n\x0erunning_levels\x18\x02 \x03(\x0b\x32\x06.Level\x12\n\n\x02\x66\x33\x18\x03 \x02(\r\x12\n\n\x02\x66\x34\x18\x04 \x02(\r\x12\n\n\x02\x66\x35\x18\x05 \x02(\r\x12\x18\n\x10transition_start\x18\x06 \x01(\r\x12\x16\n\x0etransition_end\x18\x07 \x01(\r\"k\n\x05Level\x12\r\n\x05level\x18\x01 \x02(\r\x12\n\n\x02xp\x18\x02 \x02(\r\x12\r\n\x05\x64rops\x18\x03 \x02(\r\x12\n\n\x02\x66\x34\x18\x04 \x01(\r\x12\x15\n\rentitlement_1\x18\x05 \x01(\t\x12\x15\n\rentitlement_2\x18\x06 \x01(\t')
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0blogin.proto\x1a\x16per-session-info.proto\"\x9b\x01\n\rLoginResponse\x12\x15\n\rsession_state\x18\x01 \x02(\t\x12\x1d\n\x04info\x18\x02 \x02(\x0b\x32\x0f.PerSessionInfo\x12\x18\n\x10relay_session_id\x18\x03 \x01(\r\x12\x12\n\nexpiration\x18\x04 \x01(\r\x12&\n\x0e\x65\x63onomy_config\x18\x05 \x01(\x0b\x32\x0e.EconomyConfig\"J\n\x0cLoginRequest\x12-\n\nproperties\x18\x01 \x01(\x0b\x32\x19.AnalyticsEventProperties\x12\x0b\n\x03key\x18\x02 \x02(\x0c\"0\n\x16\x41nalyticsEventProperty\x12\n\n\x02\x66\x31\x18\x01 \x02(\t\x12\n\n\x02\x66\x32\x18\x02 \x02(\t\"E\n\x18\x41nalyticsEventProperties\x12)\n\x08property\x18\x02 \x03(\x0b\x32\x17.AnalyticsEventProperty\"K\n\x1bRelaySessionRefreshResponse\x12\x18\n\x10relay_session_id\x18\x01 \x02(\r\x12\x12\n\nexpiration\x18\x02 \x02(\r\"\xa5\x01\n\rEconomyConfig\x12\x1e\n\x0e\x63ycling_levels\x18\x01 \x03(\x0b\x32\x06.Level\x12\x1e\n\x0erunning_levels\x18\x02 \x03(\x0b\x32\x06.Level\x12\n\n\x02\x66\x33\x18\x03 \x02(\r\x12\n\n\x02\x66\x34\x18\x04 \x02(\r\x12\n\n\x02\x66\x35\x18\x05 \x02(\r\x12\x18\n\x10transition_start\x18\x06 \x01(\r\x12\x16\n\x0etransition_end\x18\x07 \x01(\r\"k\n\x05Level\x12\r\n\x05level\x18\x01 \x02(\r\x12\n\n\x02xp\x18\x02 \x02(\r\x12\r\n\x05\x64rops\x18\x03 \x02(\r\x12\n\n\x02\x66\x34\x18\x04 \x01(\r\x12\x15\n\rentitlement_1\x18\x05 \x01(\t\x12\x15\n\rentitlement_2\x18\x06 \x01(\t')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'login_pb2', globals())
|
||||
|
||||
@@ -31,6 +31,10 @@ import json
|
||||
import os
|
||||
import requests
|
||||
import sys
|
||||
sys.path.insert(0, '../protobuf')
|
||||
import login_pb2
|
||||
from google.protobuf.json_format import MessageToDict
|
||||
from random import randbytes
|
||||
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
@@ -118,6 +122,33 @@ def query(session, access_token, route):
|
||||
print('HTTP Request failed: %s' % e)
|
||||
|
||||
|
||||
def api_login(session, access_token, login_request):
|
||||
try:
|
||||
response = session.post(
|
||||
url="https://us-or-rly101.zwift.com/api/users/login",
|
||||
headers={
|
||||
"Content-Type": "application/x-protobuf-lite",
|
||||
"Accept": "application/x-protobuf-lite",
|
||||
"Connection": "keep-alive",
|
||||
"Host": "us-or-rly101.zwift.com",
|
||||
"User-Agent": "Zwift/115 CFNetwork/758.0.2 Darwin/15.0.0",
|
||||
"Authorization": "Bearer %s" % access_token,
|
||||
"Accept-Language": "en-us",
|
||||
},
|
||||
data=login_request.SerializeToString(),
|
||||
verify=args.verifyCert,
|
||||
)
|
||||
|
||||
if args.verbose:
|
||||
print('Response HTTP Status Code: {status_code}'.format(
|
||||
status_code=response.status_code))
|
||||
|
||||
return response.content
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print('HTTP Request failed: %s' % e)
|
||||
|
||||
|
||||
def logout(session, refresh_token):
|
||||
# Logout
|
||||
# POST https://secure.zwift.com/auth/realms/zwift/tokens/logout
|
||||
@@ -203,6 +234,14 @@ def main(argv):
|
||||
achievements = query(session, access_token, "achievement/loadPlayerAchievements")
|
||||
with open('%s/achievements.bin' % SCRIPT_DIR, 'wb') as f:
|
||||
f.write(achievements)
|
||||
login_request = login_pb2.LoginRequest()
|
||||
login_request.key = randbytes(16)
|
||||
login_response = login_pb2.LoginResponse()
|
||||
login_response.ParseFromString(api_login(session, access_token, login_request))
|
||||
login_response_dict = MessageToDict(login_response, preserving_proto_field_name=True)
|
||||
if 'economy_config' in login_response_dict:
|
||||
with open('%s/economy_config.txt' % SCRIPT_DIR, 'w') as f:
|
||||
json.dump(login_response_dict['economy_config'], f, indent=2)
|
||||
|
||||
logout(session, refresh_token)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import sys
|
||||
sys.modules['FixTk'] = None
|
||||
|
||||
a = Analysis(['get_profile.py'],
|
||||
pathex=[],
|
||||
pathex=['../protobuf'],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
|
||||
@@ -850,6 +850,16 @@ def profile(username):
|
||||
backup_file(profile_file)
|
||||
with open(profile_file, 'wb') as f:
|
||||
f.write(profile)
|
||||
login_request = login_pb2.LoginRequest()
|
||||
login_request.key = random.randbytes(16)
|
||||
login_response = login_pb2.LoginResponse()
|
||||
login_response.ParseFromString(online_sync.api_login(session, access_token, login_request))
|
||||
login_response_dict = MessageToDict(login_response, preserving_proto_field_name=True)
|
||||
if 'economy_config' in login_response_dict:
|
||||
economy_config_file = '%s/economy_config.txt' % profile_dir
|
||||
backup_file(economy_config_file)
|
||||
with open(economy_config_file, 'w') as f:
|
||||
json.dump(login_response_dict['economy_config'], f, indent=2)
|
||||
if request.form.get("achievements"):
|
||||
achievements = online_sync.query(session, access_token, "achievement/loadPlayerAchievements")
|
||||
achievements_file = '%s/achievements.bin' % profile_dir
|
||||
|
||||
Reference in New Issue
Block a user