mirror of
https://github.com/Dielee/volvo2mqtt.git
synced 2026-08-13 11:19:52 +02:00
Add dynamic header building including latest app version
This commit is contained in:
+3
-2
@@ -1,5 +1,6 @@
|
|||||||
requests~=2.29.0
|
requests~=2.31.0
|
||||||
dynaconf~=3.1.12
|
dynaconf~=3.1.12
|
||||||
paho-mqtt~=1.6.1
|
paho-mqtt~=1.6.1
|
||||||
Babel~=2.12.1
|
Babel~=2.12.1
|
||||||
pytz~=2023.3
|
pytz~=2023.3
|
||||||
|
google_play_scraper~=1.2.6
|
||||||
+12
@@ -5,6 +5,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import config
|
import config
|
||||||
import json
|
import json
|
||||||
|
from google_play_scraper import app
|
||||||
from logging import handlers
|
from logging import handlers
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from const import units
|
from const import units
|
||||||
@@ -29,6 +30,17 @@ class SensitiveDataFilter(logging.Filter):
|
|||||||
record.msg = re.sub(pattern, "<REDACTED>", record.msg)
|
record.msg = re.sub(pattern, "<REDACTED>", record.msg)
|
||||||
return True
|
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):
|
def save_to_json(data):
|
||||||
with open('.token', 'w', encoding='utf-8') as f:
|
with open('.token', 'w', encoding='utf-8') as f:
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ def authorize(renew_tokenfile=False):
|
|||||||
auth_session = requests.session()
|
auth_session = requests.session()
|
||||||
auth_session.headers = {
|
auth_session.headers = {
|
||||||
"authorization": "Basic aDRZZjBiOlU4WWtTYlZsNnh3c2c1WVFxWmZyZ1ZtSWFEcGhPc3kxUENhVXNpY1F0bzNUUjVrd2FKc2U0QVpkZ2ZJZmNMeXc=",
|
"authorization": "Basic aDRZZjBiOlU4WWtTYlZsNnh3c2c1WVFxWmZyZ1ZtSWFEcGhPc3kxUENhVXNpY1F0bzNUUjVrd2FKc2U0QVpkZ2ZJZmNMeXc=",
|
||||||
"User-Agent": "vca-android/5.37.0",
|
"User-Agent": "vca-android/" + util.get_volvo_app_version(),
|
||||||
"Accept-Encoding": "gzip",
|
"Accept-Encoding": "gzip",
|
||||||
"Content-Type": "application/json; charset=utf-8"
|
"Content-Type": "application/json; charset=utf-8"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user