Fixed - Issue with the python upload script garminbadges-updater.py
UPDATE: Garth is fixed, it can be upgraded by: pip install garth --upgrade
The python upload script garminbadges-updater.py found here is currently not working. Garmin changed something on their side which breaks Garth (the python package that handles communication with Garmin Connect).
The issue is being discussed here: https://github.com/matin/garth/issues/73
Until it is fixed in Garth, released and the user updates the package there is a fix that works.
Locate the garth package on your computer. On my Windows machine it is found at this path:
C:\Users\[my user]\AppData\Roaming\Python\Python312\site-packages\garth
Open the file http.py in a text editor.
Locate this code:
USER_AGENT = {
"User-Agent": (
"Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) "
"AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
),
}
"User-Agent": (
"Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) "
"AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
),
}
And change it to:
USER_AGENT = {
"User-Agent": ("GCM-iOS-5.7.2.1"),
}
"User-Agent": ("GCM-iOS-5.7.2.1"),
}
Save the file and everything should work again.
Garmin Badge Database
Garmin Connect
Change country setting
Works, thanks!
ReplyDeleteGarth may be installed to `c:\Program Files\Python312\Lib\site-packages\garth\`
ReplyDeleteFound it there on Mac OS : /opt/homebrew/lib/python3.10/site-packages/garth/http.py
ReplyDeleteGarth is fixed, it can be upgraded by: pip install garth --upgrade
ReplyDeleteAdded a feature to be able to pass a username and sync for that user (this way I can have a cron that updates not only my but also my sons' account). Not the best way to send it, but it's small so maybe it'll be OK this way:
ReplyDelete------------------------------- 8< -----------------------------------------------
43a44
> userName = ""
95a97,98
> if userName != '':
> configDir += f"{userName}/"
101c104
< global debugMode
---
> global debugMode, userName
110a114,116
> if "-u" in sys.argv:
> userName = sys.argv[sys.argv.index("-u") + 1]
> #print(f"userName: {userName}")
120c126
< garth.resume("~/.garth")
---
> garth.resume(f"~/.garth/{userName}")
137c143
< garth.save("~/.garth")
---
> garth.save(f"~/.garth/{userName}")
BTW since it's open source anyway, maybe you could upload it to github
Delete