Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.get_measurements not working #186

Open
natesanshreyas opened this issue Sep 9, 2024 · 1 comment
Open

client.get_measurements not working #186

natesanshreyas opened this issue Sep 9, 2024 · 1 comment

Comments

@natesanshreyas
Copy link

Hey all,

I've had a great experience getting macros out of MFP via the MFP library, but getting weight (via get_measurements) has been really difficult for me. I'll be able to get weight for a day or so and then I'll hit this issue:

Traceback (most recent call last):
File "/Users/shreyasnatesan/Documents/python/get_weight.py", line 7, in
weight = client.get_measurements("Weight")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shreyasnatesan/Desktop/NucampFolder/Python/1-Fundamentals/myenv/lib/python3.12/site-packages/myfitnesspal/client.py", line 615, in get_measurements
measurement_ids = self._get_measurement_ids(document)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shreyasnatesan/Desktop/NucampFolder/Python/1-Fundamentals/myenv/lib/python3.12/site-packages/myfitnesspal/client.py", line 741, in _get_measurement_ids
for q in next_data_json["props"]["pageProps"]["dehydratedState"]["queries"]:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'dehydratedState'

Using scripts inclusive of what we see here:

import myfitnesspal
import browser_cookie3
from datetime import date,timedelta

client = myfitnesspal.Client(browser_cookie3.chrome())

weight = client.get_measurements("Weight")
print(weight)

I'm not sure what I'm doing wrong or if this is an issue with the library itself...

@ColorfulQuark
Copy link

That happens to me periodically. Logging out, clearing cookies and trying a couple of times usually works (or wastes time while the problem fixes itself). It's probably and issue with MFP rather than you or the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants