coddingtonbear / python-myfitnesspal

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

list index out of range #41

Closed edusteinhorst closed 7 years ago

edusteinhorst commented 8 years ago

Hi,

have been getting this error since today, when using "myfitnesspal day user":

INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): www.myfitnesspal.com                                                                                         
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): www.myfitnesspal.com                                                                                          
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.myfitnesspal.com                                                                                         
ERROR:myfitnesspal.cmdline:list index out of range
Traceback (most recent call last):                                                                                                                                                            
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/cmdline.py", line 46, in main                                                                                                     
    COMMANDS[args.command[0]]['function'](args, *extra)                                                                                                                                       
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/commands.py", line 117, in day                                                                                                    
    day = client.get_date(args.date)                                                                                                                                                          
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/client.py", line 342, in get_date                                                                                                 
    water = self._get_water(document)                                                                                                                                                         
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/client.py", line 466, in _get_water                                                                                               
    water_header = document.xpath("//div[@class='water-counter']/p/a")[0]                                                                                                                     
IndexError: list index out of range                                                                                                                                                           
Traceback (most recent call last):                                                                                                                                                            
  File "/usr/local/bin/myfitnesspal", line 9, in <module>                                                                                                                                     
    load_entry_point('myfitnesspal==1.8.3', 'console_scripts', 'myfitnesspal')()                                                                                                              
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/cmdline.py", line 46, in main                                                                                                     
    COMMANDS[args.command[0]]['function'](args, *extra)                                                                                                                                       
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/commands.py", line 117, in day                                                                                                    
    day = client.get_date(args.date)                                                                                                                                                          
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/client.py", line 342, in get_date                                                                                                 
    water = self._get_water(document)                                                                                                                                                         
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/client.py", line 466, in _get_water                                                                                               
    water_header = document.xpath("//div[@class='water-counter']/p/a")[0]                                                                                                                     
IndexError: list index out of range 
coddingtonbear commented 8 years ago

I'm afraid I can't reproduce this on my account, but I also am not tracking water there. Could you save the HTML content of the diary page for whatever date is causing the above exception, upload it as a private gist, and e-mail me a link? There's a little bit of private information in the content of the page, so you should not post the link publicly.

coddingtonbear commented 8 years ago

Hey there @edusteinhorst -- I've worked a bit with @sergekatzmann and have pushed up some changes (53b3be9 ; released as part of 1.8.4) that I think should make gathering this value a little more robust. Could you update to the latest version and give it a shot?

coddingtonbear commented 7 years ago

OK -- I think this is all sorted out now as of the most recent release (1.8.5). Using some information from @sergekatzmann in #42, I've changed both notes and water to instead make another request to gather that data. Let me know if you're still encountering problems after upgrading to the latest version.

Cheers!

edusteinhorst commented 7 years ago

Hi, sorry for taking so long to get back to you. I just tested version 1.8.6, and it's working fine. Thanks for working it out!

Cheers,

Edu