From ae0c6e234e86ed98a4523e6a4dd2a1fc6a2c6869 Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:02:28 -0300 Subject: [PATCH] Revert "Download economy config" This reverts commit 913b2f3762651fe83baaa3ab86b8f7cf7c678a3c. --- LEIAME.md | 7 +++---- README.md | 7 +++---- get_profile.py | 39 +++------------------------------- get_profile.spec | 2 +- protobuf/Makefile | 1 - protobuf/login.proto | 49 ------------------------------------------- protobuf/login_pb2.py | 38 --------------------------------- protobuf/make.bat | 1 - 8 files changed, 10 insertions(+), 134 deletions(-) delete mode 100644 protobuf/login.proto delete mode 100644 protobuf/login_pb2.py diff --git a/LEIAME.md b/LEIAME.md index 063bc8f..fae4fd2 100644 --- a/LEIAME.md +++ b/LEIAME.md @@ -18,10 +18,9 @@ Para usar o Zwift online normalmente, abra o atalho **hosts** e remova a linha c ## Para carregar as atividades no Strava (opcional): -* Obtenha o CLIENT_ID e CLIENT_SECRET de https://www.strava.com/settings/api -* Execute ``strava_auth.exe --client-id CLIENT_ID --client-secret CLIENT_SECRET`` e autorize quando o Firewall do Windows perguntar. +* Execute o **strava_auth** e autorize quando o Firewall do Windows perguntar. * Abra http://localhost:8000/ no navegador, faça login no Strava e autorize o zwift-offline a carregar suas atividades. -* Será criado um arquivo ``strava_token.txt``, mova esse arquivo para a pasta ``storage\1``. +* Será criado um arquivo **strava_token**, mova esse arquivo para a pasta ``storage\1``. * Se estiver testando, ande pelo menos 300 metros, atividades mais curtas não serão carregadas. Entre no grupo **zoffline** no Strava https://www.strava.com/clubs/zoffline @@ -30,4 +29,4 @@ Entre no grupo **zoffline** no Strava https://www.strava.com/clubs/zoffline * Desative o zwift-offline (veja [Ativando/Desativando o zwift-offline](https://github.com/oldnapalm/zoffline-helper/blob/master/LEIAME.md#ativandodesativando-o-zwift-offline) acima). * Execute o **get_profile**, digite seu login do Zwift (e-mail) e sua senha. -* Serão criados os arquivos ``profile.bin``, ``achievements.bin`` e ``economy_config.txt``, mova esses arquivos para a pasta ``storage\1``. +* Serão criados os arquivos **profile.bin** e **achievements.bin**, mova esses arquivos para a pasta ``storage\1``. diff --git a/README.md b/README.md index 607f79e..102db56 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,9 @@ To use Zwift online like normal, open the **hosts** shortcut and comment out or ## To upload activities to Strava (optional): -* Get CLIENT_ID and CLIENT_SECRET from https://www.strava.com/settings/api -* Run ``strava_auth.exe --client-id CLIENT_ID --client-secret CLIENT_SECRET`` and allow it in Windows Firewall. +* Run **strava_auth** and allow it in Windows Firewall. * Open http://localhost:8000/ and authorize. -* Move the resulting ``strava_token.txt`` into the ``storage\1`` directory. +* Move the resulting strava_token.txt into the ``storage\1`` directory. * If testing, ride at least 300 meters, shorter activities won't be uploaded. Join the **zoffline** Strava group https://www.strava.com/clubs/zoffline @@ -30,4 +29,4 @@ Join the **zoffline** Strava group https://www.strava.com/clubs/zoffline * Disable zwift-offline (see [Enabling/Disabling zwift-offline](https://github.com/oldnapalm/zoffline-helper#enablingdisabling-zwift-offline) above). * Run **get_profile**, type your Zwift login (e-mail) and password. -* Move the resulting ``profile.bin``, ``achievements.bin`` and ``economy_config.txt`` into the ``storage\1`` directory. +* Move the resulting profile.bin and achievements.bin into the ``storage\1`` directory. diff --git a/get_profile.py b/get_profile.py index 29a1c77..d0217d7 100644 --- a/get_profile.py +++ b/get_profile.py @@ -31,9 +31,6 @@ import os import requests import sys -sys.path.append(os.path.join(sys.path[0], 'protobuf')) # otherwise import in .proto does not work -import login_pb2 -from google.protobuf.json_format import MessageToDict if getattr(sys, 'frozen', False): @@ -95,7 +92,7 @@ def post_credentials(session, username, password): exit(-1) -def get(session, access_token, route): +def query(session, access_token, route): try: response = session.get( url="https://us-or-rly101.zwift.com/%s" % route, @@ -121,32 +118,6 @@ def get(session, access_token, route): print('HTTP Request failed: %s' % e) -def post(session, access_token, route): - try: - response = session.post( - url="https://us-or-rly101.zwift.com/%s" % route, - 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", - }, - 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 @@ -226,16 +197,12 @@ def main(argv): session = requests.session() access_token, refresh_token = login(session, username, password) - profile = get(session, access_token, "api/profiles/me") + profile = query(session, access_token, "api/profiles/me") with open('%s/profile.bin' % SCRIPT_DIR, 'wb') as f: f.write(profile) - achievements = get(session, access_token, "achievement/loadPlayerAchievements") + achievements = query(session, access_token, "achievement/loadPlayerAchievements") with open('%s/achievements.bin' % SCRIPT_DIR, 'wb') as f: f.write(achievements) - login_response = login_pb2.LoginResponse() - login_response.ParseFromString(post(session, access_token, "api/users/login")) - with open('%s/economy_config.txt' % SCRIPT_DIR, 'w') as f: - json.dump(MessageToDict(login_response, preserving_proto_field_name=True)['economy_config'], f, indent=2) logout(session, refresh_token) diff --git a/get_profile.spec b/get_profile.spec index a70336d..ece5b16 100644 --- a/get_profile.spec +++ b/get_profile.spec @@ -6,7 +6,7 @@ import sys sys.modules['FixTk'] = None a = Analysis(['get_profile.py'], - pathex=['protobuf'], + pathex=[], binaries=[], datas=[], hiddenimports=[], diff --git a/protobuf/Makefile b/protobuf/Makefile index 5693e22..bf45798 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -1,6 +1,5 @@ all: protoc --python_out=. activity.proto - protoc --python_out=. login.proto protoc --python_out=. profile.proto protoc --python_out=. per-session-info.proto protoc --python_out=. udp-node-msgs.proto diff --git a/protobuf/login.proto b/protobuf/login.proto deleted file mode 100644 index 21a4468..0000000 --- a/protobuf/login.proto +++ /dev/null @@ -1,49 +0,0 @@ -syntax = "proto2"; -/* XXX: This is a first approximation of login response. Not looked into or verified. */ -import "per-session-info.proto"; - -message LoginResponse { - required string session_state = 1; - required PerSessionInfo info = 2; - optional uint32 relay_session_id = 3; - optional uint32 expiration = 4; // minutes - optional EconomyConfig economy_config = 5; -} - -message LoginRequest { - required AnalyticsEventProperties properties = 1; - required bytes key = 2; -} - -message AnalyticsEventProperty { - required string f1 = 1; - required string f2 = 2; -} - -message AnalyticsEventProperties { - repeated AnalyticsEventProperty property = 2; -} - -message RelaySessionRefreshResponse { - required uint32 relay_session_id = 1; - required uint32 expiration = 2; // minutes -} - -message EconomyConfig { - repeated Level cycling_levels = 1; - repeated Level running_levels = 2; - required uint32 f3 = 3; - required uint32 f4 = 4; - required uint32 f5 = 5; - optional uint32 transition_start = 6; - optional uint32 transition_end = 7; -} - -message Level { - required uint32 level = 1; - required uint32 xp = 2; - required uint32 drops = 3; - optional uint32 f4 = 4; - optional string entitlement_1 = 5; - optional string entitlement_2 = 6; -} diff --git a/protobuf/login_pb2.py b/protobuf/login_pb2.py deleted file mode 100644 index 05a4d70..0000000 --- a/protobuf/login_pb2.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: login.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_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') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'login_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _LOGINRESPONSE._serialized_start=40 - _LOGINRESPONSE._serialized_end=195 - _LOGINREQUEST._serialized_start=197 - _LOGINREQUEST._serialized_end=271 - _ANALYTICSEVENTPROPERTY._serialized_start=273 - _ANALYTICSEVENTPROPERTY._serialized_end=321 - _ANALYTICSEVENTPROPERTIES._serialized_start=323 - _ANALYTICSEVENTPROPERTIES._serialized_end=392 - _RELAYSESSIONREFRESHRESPONSE._serialized_start=394 - _RELAYSESSIONREFRESHRESPONSE._serialized_end=469 - _ECONOMYCONFIG._serialized_start=472 - _ECONOMYCONFIG._serialized_end=637 - _LEVEL._serialized_start=639 - _LEVEL._serialized_end=746 -# @@protoc_insertion_point(module_scope) diff --git a/protobuf/make.bat b/protobuf/make.bat index f8839f0..ddaeea7 100644 --- a/protobuf/make.bat +++ b/protobuf/make.bat @@ -1,6 +1,5 @@ del *_pb2.py *_pb2.pyc protoc --python_out=. activity.proto -protoc --python_out=. login.proto protoc --python_out=. profile.proto protoc --python_out=. per-session-info.proto protoc --python_out=. udp-node-msgs.proto