Add dynamic header building including latest app version

This commit is contained in:
Linus Dietz
2024-03-15 10:27:51 +01:00
parent 701551e7e4
commit 8f210c9fd7
3 changed files with 16 additions and 3 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
requests~=2.29.0
requests~=2.31.0
dynaconf~=3.1.12
paho-mqtt~=1.6.1
Babel~=2.12.1
pytz~=2023.3
pytz~=2023.3
google_play_scraper~=1.2.6
+12
View File
@@ -5,6 +5,7 @@ import re
import sys
import config
import json
from google_play_scraper import app
from logging import handlers
from datetime import datetime
from const import units
@@ -29,6 +30,17 @@ class SensitiveDataFilter(logging.Filter):
record.msg = re.sub(pattern, "<REDACTED>", record.msg)
return True
def get_volvo_app_version():
result = app(
'se.volvo.vcc',
lang='en',
country='us'
)
if "version" in result:
return result["version"]
else:
return "5.37.0"
def save_to_json(data):
with open('.token', 'w', encoding='utf-8') as f:
+1 -1
View File
@@ -46,7 +46,7 @@ def authorize(renew_tokenfile=False):
auth_session = requests.session()
auth_session.headers = {
"authorization": "Basic aDRZZjBiOlU4WWtTYlZsNnh3c2c1WVFxWmZyZ1ZtSWFEcGhPc3kxUENhVXNpY1F0bzNUUjVrd2FKc2U0QVpkZ2ZJZmNMeXc=",
"User-Agent": "vca-android/5.37.0",
"User-Agent": "vca-android/" + util.get_volvo_app_version(),
"Accept-Encoding": "gzip",
"Content-Type": "application/json; charset=utf-8"
}