Skip to content

Commit

Permalink
Revert "Download economy config"
Browse files Browse the repository at this point in the history
This reverts commit 913b2f3.
  • Loading branch information
oldnapalm committed Aug 8, 2024
1 parent 913b2f3 commit ae0c6e2
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 134 deletions.
7 changes: 3 additions & 4 deletions LEIAME.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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``.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
39 changes: 3 additions & 36 deletions get_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion get_profile.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sys
sys.modules['FixTk'] = None

a = Analysis(['get_profile.py'],
pathex=['protobuf'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
Expand Down
1 change: 0 additions & 1 deletion protobuf/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
49 changes: 0 additions & 49 deletions protobuf/login.proto

This file was deleted.

38 changes: 0 additions & 38 deletions protobuf/login_pb2.py

This file was deleted.

1 change: 0 additions & 1 deletion protobuf/make.bat
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ae0c6e2

Please sign in to comment.