Update Garmin Connect upload

This commit is contained in:
oldnapalm
2023-09-28 09:31:37 -03:00
parent 66dd9bc3d1
commit 11e52633a0
4 changed files with 9 additions and 11 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ jobs:
pathInArchive: "upx-4.0.2-win64/upx.exe"
- run: pip install -r requirements.txt
- run: pip install pyinstaller git+https://github.com/oldnapalm/garmin-uploader.git
- run: pip install pyinstaller garth
- run: pyinstaller standalone.spec
- uses: vimtor/action-zip@v1
+1 -1
View File
@@ -8,7 +8,7 @@ RUN git clone --depth 1 https://github.com/zoffline/zwift-offline
COPY requirements.txt requirements.txt
RUN pip install --user --requirement requirements.txt
RUN pip install --user git+https://github.com/oldnapalm/garmin-uploader.git
RUN pip install --user garth
FROM python:3.11-alpine
MAINTAINER zoffline <zoffline@tutanota.com>
+2 -3
View File
@@ -269,8 +269,7 @@ To obtain your current profile:
<details><summary>Expand</summary>
* If running from source, install garmin-uploader: ``pip install git+https://github.com/oldnapalm/garmin-uploader.git``
* If the upload fails you can try the selenium method: ``pip uninstall -y garmin-uploader ; pip install git+https://github.com/ursoft/garmin-uploader.git@cloudscraper selenium webdriver_manager``
* If running from source, install garth: ``pip install garth``
* __NOTE:__ instead of performing the step below you can instead use the "Settings - Garmin" button in the launcher window to enter your credentials (Windows and macOS only).
* Create a file ``garmin_credentials.txt`` in the ``storage/1`` directory containing your login credentials
```
@@ -362,7 +361,7 @@ Docker
* dnspython (https://www.dnspython.org/)
* fitdecode (https://pypi.org/project/fitdecode/)
* stravalib (https://github.com/hozn/stravalib)
* OPTIONAL: garmin-uploader (https://github.com/La0/garmin-uploader)
* OPTIONAL: garth (https://pypi.org/project/garth/)
* OPTIONAL: discord.py (https://discordpy.readthedocs.io/)
+5 -6
View File
@@ -2057,9 +2057,9 @@ def strava_upload(player_id, activity):
def garmin_upload(player_id, activity):
try:
from garmin_uploader.workflow import Workflow
import garth
except ImportError as exc:
logger.warning("garmin_uploader is not installed. Skipping Garmin upload attempt: %s" % repr(exc))
logger.warning("garth is not installed. Skipping Garmin upload attempt: %s" % repr(exc))
return
profile_dir = '%s/%s' % (STORAGE_DIR, player_id)
garmin_credentials = '%s/garmin_credentials' % profile_dir
@@ -2082,11 +2082,10 @@ def garmin_upload(player_id, activity):
except Exception as exc:
logger.warning("Failed to read %s. Skipping Garmin upload attempt: %s" % (garmin_credentials, repr(exc)))
return
with open('%s/last_activity.fit' % profile_dir, 'wb') as f:
f.write(activity.fit)
try:
w = Workflow(['%s/last_activity.fit' % profile_dir], activity_name=activity.name, username=username, password=password)
w.run()
garth.login(username, password)
requests.post('https://connect.garmin.com/upload-service/upload/.fit', files={'file': BytesIO(activity.fit)},
headers={'NK': 'NT', 'authorization': garth.client.oauth2_token.__str__(), 'di-backend': 'connectapi.garmin.com'})
except Exception as exc:
logger.warning("Garmin upload failed. No internet? %s" % repr(exc))