coddingtonbear / python-myfitnesspal

Access your meal tracking data stored in MyFitnessPal programatically
MIT License
789 stars 138 forks source link

Unpacking Values after 2.0.0 Update: #145

Closed chazzaspazz closed 1 year ago

chazzaspazz commented 1 year ago

Hi Guys,

Apologies if this is a simple fix or stupid question, but after the recent update, when using cookie jar I am getting the following Error:

Traceback (most recent call last):
  File "/Users/charliebutcher/Library/Mobile Documents/com~apple~CloudDocs/100_Days_of_Python/MFP/main.py", line 1, in <module>
    from sheety import SheetUpdate
  File "/Users/charliebutcher/Library/Mobile Documents/com~apple~CloudDocs/100_Days_of_Python/MFP/sheety.py", line 2, in <module>
    from data_manager import DataManager
  File "/Users/charliebutcher/Library/Mobile Documents/com~apple~CloudDocs/100_Days_of_Python/MFP/data_manager.py", line 7, in <module>
    client = myfitnesspal.Client(MFP_Name, MFP_PW)
  File "/Users/charliebutcher/Library/Mobile Documents/com~apple~CloudDocs/100_Days_of_Python/MFP/venv/lib/python3.10/site-packages/myfitnesspal/client.py", line 76, in __init__
    self.session.cookies.update(cookiejar)
  File "/Users/charliebutcher/Library/Mobile Documents/com~apple~CloudDocs/100_Days_of_Python/MFP/venv/lib/python3.10/site-packages/requests-2.26.0-py3.10.egg/requests/cookies.py", line 354, in update
    super(RequestsCookieJar, self).update(other)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/_collections_abc.py", line 996, in update
    for key, value in other:
ValueError: not enough values to unpack (expected 2, got 1)`

Any idea on what I might be able to do to fix this?

Thanks!

ColorfulQuark commented 1 year ago

You no longer call client with username and password. Use:

client = myfitnesspal.Client()

not

client = myfitnesspal.Client(MFP_Name, MFP_PW)

I didn't notice this until I looked at the source code for client.py

coddingtonbear commented 1 year ago

I've just posted a doc that outlines the upgrade path between the 1.x and 2.x versions; have a look at https://python-myfitnesspal.readthedocs.io/en/latest/upgrading.html.