mirror of
https://github.com/zoffline/zwift-offline.git
synced 2026-03-12 21:23:00 -07:00
Update scripts
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import os
|
||||
import sys
|
||||
import csv
|
||||
sys.path.append(os.path.join(sys.path[0], 'protobuf')) # otherwise import in .proto does not work
|
||||
sys.path.insert(0, '../protobuf')
|
||||
import profile_pb2
|
||||
import udp_node_msgs_pb2
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ def main(argv):
|
||||
session = requests.session()
|
||||
access_token, refresh_token, expired_in = post_credentials(session, username, password)
|
||||
game_info = get_game_info(session, access_token).decode('utf-8')
|
||||
with open('game_info.txt', 'wb') as f:
|
||||
with open('../game_info.txt', 'wb') as f:
|
||||
f.write(game_info.encode('utf-8-sig'))
|
||||
|
||||
logout(session, refresh_token)
|
||||
|
||||
@@ -31,7 +31,7 @@ import json
|
||||
import os
|
||||
import requests
|
||||
import sys
|
||||
sys.path.append(os.path.join(sys.path[0], 'protobuf')) # otherwise import in .proto does not work
|
||||
sys.path.insert(0, '../protobuf')
|
||||
import activity_pb2
|
||||
import profile_pb2
|
||||
|
||||
|
||||
@@ -1,30 +1,21 @@
|
||||
import json
|
||||
import protobuf.variants_pb2 as variants_pb2
|
||||
import sys
|
||||
sys.path.insert(0, '../protobuf')
|
||||
import variants_pb2
|
||||
from google.protobuf.json_format import MessageToDict
|
||||
|
||||
variants = variants_pb2.FeatureResponse()
|
||||
|
||||
with open("variant", "rb") as f:
|
||||
variants = variants_pb2.FeatureResponse()
|
||||
variants.ParseFromString(f.read())
|
||||
|
||||
vs = []
|
||||
with open("../variants.txt") as f:
|
||||
vs = json.load(f)['variants']
|
||||
|
||||
with open("variants.txt") as f:
|
||||
j = json.load(f)
|
||||
vs = j['variants']
|
||||
|
||||
for variant in variants.variants:
|
||||
d = MessageToDict(variant)
|
||||
v = {}
|
||||
v['name'] = d['name']
|
||||
if 'value' in d:
|
||||
v['value'] = d['value']
|
||||
d['values'] = dict(d['values'])
|
||||
for f in d['values']:
|
||||
d['values'][f] = dict(sorted(d['values'][f].items()))
|
||||
v['values'] = d['values']
|
||||
for v in MessageToDict(variants)['variants']:
|
||||
if 'fields' in v['values']:
|
||||
v['values']['fields'] = dict(sorted(v['values']['fields'].items()))
|
||||
vs[:] = [d for d in vs if d.get('name') != v['name']]
|
||||
vs.append(v)
|
||||
|
||||
with open("variants.txt", "w") as f:
|
||||
with open("../variants.txt", "w") as f:
|
||||
json.dump({'variants': sorted(vs, key=lambda x: x['name'])}, f, indent=2)
|
||||
|
||||
Reference in New Issue
Block a user