cyberjunky / python-garminconnect

Python 3 API wrapper for Garmin Connect to get activity statistics
MIT License
908 stars 142 forks source link

Download_activity is broken with Garth #155

Closed julienroulle closed 1 year ago

julienroulle commented 1 year ago

Tried upgrading garminconnect today, and the download_activity in one of my scripts failed. I tried the example.py file in the repo, and the same thing happened.

api.download_activity(12052308637, dl_fmt=api.ActivityDownloadFormat.GPX)
Traceback (most recent call last):
  File "example.py", line 666, in <module>
    switch(api, option)
  File "example.py", line 382, in switch
    gpx_data = api.download_activity(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "garminconnect/__init__.py", line 832, in download_activity
    return self.download(url)
           ^^^^^^^^^^^^^^^^^^
  File "garminconnect/__init__.py", line 154, in download
    return self.garth.download(path, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'download'

I am not sure what Garth is, so I don't have any solution (yet). I'll try and have a look at it later

cyberjunky commented 1 year ago

Garth is the name of another garminconnect package, and we now use the authentication and data fetching api only, instead of the code we had, the rest is the same. The advantage of Garth is that it uses the mobile app endpoints instead of the website, the mobile endpoints don't have Cloudflare in between (if I'm correct)

I just tested downloading with example.py (option p) and it still works here. I think your code is wrong, the calls are like this where api is not garth, but just like below and there is no .download() it's called download_activity()

api = Garmin(email, password)
api.login()

gpx_data = api.download_activity(
       activity_id, dl_fmt=api.ActivityDownloadFormat.GPX
)
julienroulle commented 1 year ago

Thanks for your answer. You are right.

My problem was that garth was at version 0.4.18, because I need to have pydantic on version 1, because of sqlmodel. But garth 0.4.25 needs pydantic > 2. Now with garth 0.4.25 i can confirm download is working, but it does not work with previous versions of garth

cyberjunky commented 1 year ago

Ah oke, Garth is new for me too, thanks for the update. Can I close it?

matin commented 1 year ago

This issue was also reported in https://github.com/cyberjunky/python-garminconnect/issues/141#issuecomment-1714259761.

It was fixed in 0.4.23.

@cyberjunky I recommend making 0.4.23 the minimum version in pyproject.toml. Doing so would ensure no one else faces this issue.

matin commented 1 year ago

@julienroulle Garth 0.4.34 now supports Pydantic >= 1.10.13, which is within the supported range of sqlmodel. See #162 for more details.

julienroulle commented 1 year ago

@julienroulle Garth 0.4.34 now supports Pydantic >= 1.10.13, which is within the supported range of sqlmodel. See #162 for more details.

Really appreciate you taking the time to update me on this. Thanks for your work !