After recently switching to an intermittent fasting plan, I've been seeking a solution for MyFitnessPal to support different macros on different days. A fellow coworker who's already lost 50lb on an IF plan pointed me to a reddit thread with a MFP custom macro script. It's an excellent little script and macro but I ran into some issues getting it to work.
I started by attempting to run the script via OSX on my Macbook but found I had to install the Mechanize extension for Python. No big deal but when I ran the script for the first time, I got a what looked to be an Mechanize error which kind of threw me off. After digging around, I found the fix on another related reddit thread. That fixed the authentication issue but then the script failed again with a similar error related to the 'totalCallories' variable.
I started by attempting to run the script via OSX on my Macbook but found I had to install the Mechanize extension for Python. No big deal but when I ran the script for the first time, I got a what looked to be an Mechanize error which kind of threw me off. After digging around, I found the fix on another related reddit thread. That fixed the authentication issue but then the script failed again with a similar error related to the 'totalCallories' variable.
Turns out the error maps to the script side here:macbook:site-packages user$ python macros.pySchedule section existsSunday is: RAll configuration options presentLogging inLogin sentLogin response receivedLogin successfulOpening custom goals pageCustom goals page loadedTraceback (most recent call last):File "macros.py", line 92, in <module>br.form["goals_nutrient_calories"]=targetCaloriesFile "build/bdist.macosx-10.9-intel/egg/mechanize/_form.py", line 2780, in __setitem__File "build/bdist.macosx-10.9-intel/egg/mechanize/_form.py", line 3101, in find_controlFile "build/bdist.macosx-10.9-intel/egg/mechanize/_form.py", line 3185, in _find_controlmechanize._form.ControlNotFoundError: no control matching name 'goals_nutrient_calories'
br.select_form(nr=0)It appears MFP made some additional changes on their side since the script was posted in 2012 and the prior fix was posted to reddit a year ago. After a little digging in the web source code, I found the MFP website was using new variable names on the custom calorie goals web form. Making the following changes resolved the issue:
br.form["nutrient_goal[calories]"]=targetCalories
br.form["nutrient_goal[carb_ratio]"]=[targetCarb]
br.form["nutrient_goal[protein_ratio]"]=[targetProtein]
br.form["nutrient_goal[fat_ratio]"]=[targetFat]
br.select_form(nr=0)That was the last hurdle for me. The script is now working great! Next up, I'll be exploring some ways to automate the script with into Google Sheets.
br.form["goals[nutrient_calories]"]=targetCalories
br.form["goals[carb_ratio]"]=[targetCarb]
br.form["goals[protein_ratio]"]=[targetProtein]
br.form["goals[fat_ratio]"]=[targetFat]
Generally 20-25% of normal calories are allowed to be consumed on fasting days; so if you normally consume 2000 calories on regular eating days, you would be allowed 400-500 calories on fasting days. intermittent fasting plan
ReplyDelete10 Best Youtube Sports Betting Youtube Channel - CURIOUS
ReplyDeleteIt's been around since 2020, and we don't have any more videos than youtube, so here youtube to mp3 converter reviews is a list of 10.tv channels, and what they do have.