Skip to content

Commit

Permalink
Add dynamic header building including latest app version
Browse files Browse the repository at this point in the history
  • Loading branch information
Dielee committed Mar 15, 2024
1 parent 701551e commit 8f210c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import config
import json
from google_play_scraper import app
from logging import handlers
from datetime import datetime
from const import units
Expand All @@ -29,6 +30,17 @@ def filter(self, record: logging.LogRecord) -> bool:
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:
Expand Down
2 changes: 1 addition & 1 deletion src/volvo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 8f210c9

Please sign in to comment.