GithubHelp home page GithubHelp logo

coddingtonbear / python-myfitnesspal Goto Github PK

View Code? Open in Web Editor NEW
793.0 34.0 138.0 441 KB

Access your meal tracking data stored in MyFitnessPal programatically

License: MIT License

Python 100.00%

python-myfitnesspal's Introduction

python-myfitnesspal's People

Contributors

acrose99 avatar agbrook avatar alangrenfell avatar aleenacodes avatar bradgarropy avatar cclauss avatar coddingtonbear avatar dlgoodr avatar dnic94 avatar ehershey avatar gg avatar gitter-badger avatar hannahburkhardt avatar hbmartin avatar hillwithsmallfields avatar ianozsvald avatar jat255 avatar jtszalay avatar judgewooden avatar justyn avatar kb1900 avatar kittenwhisky avatar plandes avatar pydolan avatar rbelzile avatar samhinshaw avatar sean-freeman avatar sgtcodfish avatar surye avatar tsatska avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-myfitnesspal's Issues

get_date() is returning blank

client.get_date() is returning blank (get_measurements() is probably also affected).

This seems to be because in _get_url_for_date the URL is constructed using self.BASE_URL (http://www.myfitnesspal.com/)

The requests session is created with a a POST to login_url which is constructed using self.BASE_URL_SECURE (https://www.myfitnesspal.com).

When get_date() tries to use the same requests session to make a GET request to /food/diary/username, no cookies are submitted because the protocol is different, and no data is returned unless the client has their food diary set to public.

The solution seems to be to construct the URL for date using self.BASE_URL_SECURE.

This issue might have been masked before if MFP were redirecting all requests to HTTPS.

Water intake supplied in ml

The docs should either say that the water given is in OZ or ML, not sure if conversions are done internally, but seems like despite changing MFP unit settings, the water intake is still supplied in ML.

Always returns today

Hi,

Thanks for creating this great module!

I'm running into an issue where no matter what date I supply I get back today's data.

Example:
image

Thanks for your help
David

get_date not working

Currently get_date errors out with the following message:

Traceback (most recent call last):
File "test.py", line 15, in
day = client.get_date(today)
File "/usr/local/lib/python2.7/site-packages/myfitnesspal/client.py", line 222, in get_date
goals = self._get_goals(document)
File "/usr/local/lib/python2.7/site-packages/myfitnesspal/client.py", line 122, in _get_goals
total_header = document.xpath("//tr[@Class='total']")[0]
IndexError: list index out of range

This happens regardless of the date requested.

list index out of range

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 

Quick Add

Hi,
I just had a quick play around with adding a Quick Add method to the API.
I get a 202 though, which is weird and it doesn't add the data to the website.
Wondering if anyone had any experience with this?

The code is pretty rough at the moment so not really ready for a pull request, but I could dump it in a GIST if someone might have an idea on why it doesn't work.

I guess they must be doing something extra with the previous requests when trying to "quick add".

Support for retrieving friend's food log

Why

Some people talk to their friends (which whom they are also friends on MyFitnessPal) about their food diary and want to obtain insights. However, not all people in such a group are able to run Python code to analyze their data, nor are they willing to share their password.

What

  • get_date method accepts a friend_name optional argument which causes it to use that instead of self.username

Notes

I will create my own fork and create a pull request for this, as I need it pretty quickly :) Thanks for creating this client!

Command line utilities don't work out of the box on Windows 10

When trying to run from the command line the myfitnesspal script fails when trying to load _curses:

(py2) C:\Users\austi>myfitnesspal
Traceback (most recent call last):
  File "c:\users\austi\anaconda2\envs\py2\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\users\austi\anaconda2\envs\py2\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Users\austi\Anaconda2\envs\py2\Scripts\myfitnesspal.exe\__main__.py", line 5, in <module>
  File "c:\users\austi\anaconda2\envs\py2\lib\site-packages\myfitnesspal\cmdline.py", line 6, in <module>
    from .commands import COMMANDS, get_command_list
  File "c:\users\austi\anaconda2\envs\py2\lib\site-packages\myfitnesspal\commands.py", line 8, in <module>
    from blessed import Terminal
  File "c:\users\austi\anaconda2\envs\py2\lib\site-packages\blessed\__init__.py", line 10, in <module>
    from blessed.terminal import Terminal
  File "c:\users\austi\anaconda2\envs\py2\lib\site-packages\blessed\terminal.py", line 8, in <module>
    import curses
  File "c:\users\austi\anaconda2\envs\py2\lib\curses\__init__.py", line 15, in <module>
    from _curses import *
ImportError: No module named _curses

I've attached my conda environment to help reproduce the issue.

atkeller_env.yaml.txt

FileNotFoundError when using myfitnesspal.Client()

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/util/ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir)

FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    422         if isinstance(timeout, tuple):
--> 423             try:
    424                 connect, read = timeout

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, **response_kw)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py in _validate_conn(self, conn)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connection.py in connect(self)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/util/ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir)

SSLError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
<ipython-input-85-2f7865374943> in <module>
      2 
      3 
----> 4 myfitnesspal.Client(username = '')
      5 
      6 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in __init__(self, username, password, login, unit_aware)
     56         self.session = requests.Session()
     57         if login:
---> 58             self._login()
     59 
     60     @property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _login(self)
     84     def _login(self):
     85         login_url = parse.urljoin(self.BASE_URL_SECURE, self.LOGIN_PATH)
---> 86         document = self._get_document_for_url(login_url)
     87         authenticity_token = document.xpath(
     88             "(//input[@name='authenticity_token']/@value)[1]"

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_document_for_url(self, url)
    210 
    211     def _get_document_for_url(self, url):
--> 212         content = self._get_content_for_url(url)
    213 
    214         return lxml.html.document_fromstring(content)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_content_for_url(self, *args, **kwargs)
    206     def _get_content_for_url(self, *args, **kwargs):
    207         return (
--> 208             self._get_request_for_url(*args, **kwargs).content.decode('utf8')
    209         )
    210 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_request_for_url(self, url, send_token, headers, **kwargs)
    201             url,
    202             headers=headers,
--> 203             **kwargs
    204         )
    205 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py in get(self, url, **kwargs)
    486             for multipart encoding upload.
    487         :param auth: (optional) Auth tuple or callable to enable
--> 488             Basic/Digest/Custom HTTP Auth.
    489         :param timeout: (optional) How long to wait for the server to send
    490             data before giving up, as a float, or a :ref:`(connect timeout,

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    473         :param method: method for the new :class:`Request` object.
    474         :param url: URL for the new :class:`Request` object.
--> 475         :param params: (optional) Dictionary or bytes to be sent in the query
    476             string for the :class:`Request`.
    477         :param data: (optional) Dictionary, list of tuples, bytes, or file-like

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py in send(self, request, **kwargs)
    594 
    595     def patch(self, url, data=None, **kwargs):
--> 596         r"""Sends a PATCH request. Returns :class:`Response` object.
    597 
    598         :param url: URL for the new :class:`Request` object.

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    495                     raise
    496 
--> 497         except (ProtocolError, socket.error) as err:
    498             raise ConnectionError(err, request=request)
    499 

SSLError: [Errno 2] No such file or directory

HtmlElement has no attribute classes

Seems to be a small hole in error handling?

>>> import myfitnesspal
>>> client = myfitnesspal.Client('Cokemonkey11')
>>> day = client.get_date(2017, 9, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 482, in get_date
    complete = self._get_completion(document)
  File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 259, in _get_completion
    if "day_incomplete_message" in completion_message.classes:
AttributeError: 'HtmlElement' object has no attribute 'classes'

Thanks for your work on this!

myfitnesspal.Client('my_username') returns JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Hi,

first , my environment : Win10 Pro /anaconda 1.8.5 / python 3.6.4

After having stored my password with
$myfitnesspal store-password my_username

the client connection with
$client = myfitnesspal.Client('my_username')
is returning below error and I cannot figure out what is wrong .
Did you already experiment such error ?

thx in advance

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-21-3d3db237c829> in <module>()
      6 
      7 #Connection with my credentials
----> 8 client = myfitnesspal.Client('my_username')
      9 
     10 day = client.get_date(2018, 12, 3)

~\Anaconda3\lib\site-packages\myfitnesspal\client.py in __init__(self, username, password, login, unit_aware)
     50         self.session = requests.Session()
     51         if login:
---> 52             self._login()
     53 
     54     @property

~\Anaconda3\lib\site-packages\myfitnesspal\client.py in _login(self)
    103             )
    104 
--> 105         self._auth_data = self._get_auth_data()
    106         self._user_metadata = self._get_user_metadata()
    107 

~\Anaconda3\lib\site-packages\myfitnesspal\client.py in _get_auth_data(self)
    124             )
    125 
--> 126         return result.json()
    127 
    128     def _get_user_metadata(self):

~\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs)
    890                     # used.
    891                     pass
--> 892         return complexjson.loads(self.text, **kwargs)
    893 
    894     @property

~\Anaconda3\lib\json\__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    352             parse_int is None and parse_float is None and
    353             parse_constant is None and object_pairs_hook is None and not kw):
--> 354         return _default_decoder.decode(s)
    355     if cls is None:
    356         cls = JSONDecoder

~\Anaconda3\lib\json\decoder.py in decode(self, s, _w)
    337 
    338         """
--> 339         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    340         end = _w(s, end).end()
    341         if end != len(s):

~\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)
    355             obj, end = self.scan_once(s, idx)
    356         except StopIteration as err:
--> 357             raise JSONDecodeError("Expecting value", s, err.value) from None
    358         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Document is empty

Sorry, this is probably just a screw-up on my side.
I can access my account via the command line, but when I copy/paste the very first example as a script I get a ParserError: Document is empty

SSL error

I seem to have installed this successfully, but I can't actually get any data from MFP. The credentials below are correct for a dummy account I set up:

import myfitnesspal
client = myfitnesspal.Client('dummyaccount123', 'password')
Traceback (most recent call last):
File "", line 1, in
File "myfitnesspal/client.py", line 38, in init
self._login()
File "myfitnesspal/client.py", line 42, in _login
document = self._get_document_for_url(login_url)
File "myfitnesspal/client.py", line 83, in _get_document_for_url
content = self._get_content_for_url(url)
File "myfitnesspal/client.py", line 80, in _get_content_for_url
return self.session.get(url).content.decode('utf8')
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-1.2.3-py2.7.egg/requests/sessions.py", line 347, in get
return self.request('GET', url, *_kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-1.2.3-py2.7.egg/requests/sessions.py", line 335, in request
resp = self.send(prep, *_send_kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-1.2.3-py2.7.egg/requests/sessions.py", line 438, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-1.2.3-py2.7.egg/requests/adapters.py", line 331, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm

New error

Unable to fetch user metadata; this may cause Myfitnesspal to behave incorrectly if you have logged-in with your e-mail address rather than your basic username; status 504

my program was working last week so this is a new error

JSONDecodeError Traceback (most recent call last)
in 
----> 1 client = myfitnesspal.Client('username_example')
2
3 Day = client.get_date(begin_year, begin_month, begin_day)
4 Date = str(today)
5

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in init(self, username, password, login, unit_aware)
56 self.session = requests.Session()
57 if login:
---> 58 self._login()
59
60 @Property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _login(self)
110
111 self._auth_data = self._get_auth_data()
--> 112 self._user_metadata = self._get_user_metadata()
113
114 # authenticity token required for measurement set function.

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_user_metadata(self)
161 )
162
--> 163 return result.json()['item']
164
165 def _get_full_name(self, raw_name):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py in json(self, **kwargs)
894 # used.
895 pass
--> 896 return complexjson.loads(self.text, **kwargs)
897
898 @Property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 parse_int is None and parse_float is None and
347 parse_constant is None and object_pairs_hook is None and not kw):
--> 348 return _default_decoder.decode(s)
349 if cls is None:
350 cls = JSONDecoder

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

ValueError: Expecting value: line 1 column 1 (char 0)

import myfitnesspal as mfp

client=mfp.Client('vaasitas')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 52, in init
self._login()
File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 105, in _login
self._auth_data = self._get_auth_data()
File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 126, in _get_auth_data
return result.json()
File "/usr/local/lib/python3.4/dist-packages/requests/models.py", line 896, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.4/json/init.py", line 318, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

Add exercise to documentation

Looks like exercises was added recently. I'm struggling to figure out how to use it, so some documentation would be great!

Steps towards Python 3.4 compatibility

Hello, I'm a Python 3.4 user, your library seems to be for Python 2.7 only. I've done a little work to update a local copy, if others are on Python 3.4 then maybe I should try to build a PR?
I removed the requirements.txt (and the reference in setup.py) as the requirements are hardcoded to older versions of tools
Using Anaconda and conda I installed requests 2.7, lxml 3.4.4, measurement 1.5 (as you specified) and I didn't install ordereddict.
References to ordereddict are replaced with from collections import OrderedDict as ordereddict as OrderedDict is built-in
A couple of unicode references are fixed

Python 2.7 has OrderedDict in collections, so the only reason to install ordereddict would be for e.g. Python 2.6 support (is that still supported?).

mimic installs but doesn't seem to have the methods you're expecting in the tests, so my conversion doesn't run py.test sadly.

Otherwise - cool! I've got data downloads now for diet analysis :-)

Add support to retrieve measurements

Why

Some MyFitnessPal users like myself are interested in calculating how their body metrics are changing on a daily, weekly, or monthly basis. Measurements like weight and body fat are particularly important to track while bulking or cutting in order to gauge weight changes week over week.

What

I would like to add support to retrieve measurements from MyFitnessPal. Measurement names are defined by the user and their values are stored accordingly based on the date. You can view measurements on the page pictured below.

measurements

How

Measurements can be scraped from the MyFitnessPal URLs in this format:
http://www.myfitnesspal.com/measurements/username/edit?page=1&type=1

The page value can be altered to scroll through dates and the type value can be altered based on which measurement you want to view. User defined measurements, like body fat percentage for example, come with a type that looks to be a hashed value of the name. These are listed in the HTML like so:

<select class="select" id="type" name="type">
<option value="1" selected="selected">Weight</option>
<option value="90533147">Body Fat</option>
<option value="92749113">Bicep</option>
<option value="92749117">Chest</option>
<option value="92749121">Waist</option>
<option value="92749122">Shoulders</option></select>

Based on this information we can correlate the measurement name with the type value. The measurements and values are in the HTML in a very straightforward manner.

<tr>
    <td class="first">
        Weight
    </td>
    <td class="col-num">4/22/2015</td>
    <td class="col-num">173.2 lbs</td>
    </td>
    <td>
        <a href="/measurements/delete/169726739" class="remove" data-confirm="Are you sure you want to delete this entry?">Delete?</a>
    </td>
</tr>

Notes

If you are in agreement about adding this feature, I will fork this repository with a branch name of add-measurement-support, and start developing!

I would like to hear your feedback about everything, and especially these points.

  • Extend the client.get_date method or create a new client.get_measurement method.
  • The data structure that will contain measurement information.

Unable to log in

Running python 2.7 on mac osx. When I try to run

myfitnesspal.Client('username', 'password')

I get

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/myfitnesspal-1.12.0-py2.7.egg/myfitnesspal/client.py", line 52, in __init__ self._login() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/myfitnesspal-1.12.0-py2.7.egg/myfitnesspal/client.py", line 80, in _login document = self._get_document_for_url(login_url) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/myfitnesspal-1.12.0-py2.7.egg/myfitnesspal/client.py", line 206, in _get_document_for_url content = self._get_content_for_url(url) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/myfitnesspal-1.12.0-py2.7.egg/myfitnesspal/client.py", line 202, in _get_content_for_url self._get_request_for_url(*args, **kwargs).content.decode('utf8') File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/myfitnesspal-1.12.0-py2.7.egg/myfitnesspal/client.py", line 197, in _get_request_for_url **kwargs File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 525, in get return self.request('GET', url, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 512, in request resp = self.send(prep, **send_kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 622, in send r = adapter.send(request, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/adapters.py", line 495, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))

I'm confident my username and password are correct. Any help is appreciated.

The script does not like special characters

myfitnesspal crashes if there are special characters in the output:

ERROR:myfitnesspal.cmdline:'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)
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 125, in day
    print('* {entry.name}'.format(entry=entry))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/local/bin/myfitnesspal", line 9, in <module>
    load_entry_point('myfitnesspal==1.8.0', '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 125, in day
    print('* {entry.name}'.format(entry=entry))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)

Unfortunately there are many special characters in Swiss-German :-). Therefore the tool does only export one day of the last 14...

IndexError: list index out of range in _get_goals

Hi,
Sometimes I'm experiencing IndexError when calling get_date:

18:59:24 web.1    |     day = mfp_client.get_date(single_date)
18:59:24 web.1    |   File "/home/vagrant/envs/vagrant/lib/python2.7/site-packages/myfitnesspal/client.py", line 481, in get_date
18:59:24 web.1    |     goals = self._get_goals(document)
18:59:24 web.1    |   File "/home/vagrant/envs/vagrant/lib/python2.7/site-packages/myfitnesspal/client.py", line 235, in _get_goals
18:59:24 web.1    |     total_header = document.xpath("//tr[@class='total']")[0]
18:59:24 web.1    | IndexError: list index out of range

I'm preparing PR for this and will assign it with this issue.

Thanks,
Mike

IndexError in _get_goals

Hello @coddingtonbear,
I believe I have found an issue when running _get_goals. In fact, the same issue as #12 .
I am running v1.6 (downloaded today) and Python version 2.7.10. See extract below (username and password changed).

$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import myfitnesspal
>>> client = myfitnesspal.Client('username','password')
>>> day = client.get_date(2015,1,1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/myfitnesspal-1.6-py2.7.egg/myfitnesspal/client.py", line 222, in get_date
    goals = self._get_goals(document)
  File "/Library/Python/2.7/site-packages/myfitnesspal-1.6-py2.7.egg/myfitnesspal/client.py", line 122, in _get_goals
    total_header = document.xpath("//tr[@class='total']")[0]
IndexError: list index out of range

I have checked client.py on my system and it includes the fix to #12.

I am happy to provide additional information if required.

@ojcm

Add License.txt

Hi,

Thanks for putting this library up here, I'm looking forward to playing around with it. What license are you placing it under?

Cheers!

Exercise Data

Had a cursory look at the code and I'm not sure if this library has this feature.
Can I pull exercise data with this? If not you know any other good libraries for this?

Can't find a way to retrieve friends data

I was looking at issue #6 , but I can't find the way of passing the 4th parameter, friend_name. Inside the code there is still a comment that say "when looking a friend profile, the html is different", so I guess that ths function is still supported, but i can't find a way to do it without cloning the repo and edit the code.
Thanks in advance.

Flavio

Error in calling client

import myfitnesspal as mfp

client=mfp.Client('vaasitas')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 52, in init
self._login()
File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 105, in _login
self._auth_data = self._get_auth_data()
File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 126, in _get_auth_data
return result.json()
File "/usr/local/lib/python3.4/dist-packages/requests/models.py", line 896, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.4/json/init.py", line 318, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

"OrderedDict mutated during iteration" - Python 3.5

I've found what I believe is a new bug in the code, and I believe it's a new error message introduced in Python 3.5. The issue is that measurements.keys() does not return a copy, so it should not be modified while iterating.

The fix is simple - I changed line 294 from:

for date in measurements.keys():

to:

for date in list(measurements.keys()):

And that solves the problem -- list returns a copy, essentially.

Best,
David

Traceback log:


RuntimeError Traceback (most recent call last)
in ()
2 lastweek = datetime.date(2015, 12, 30)
3
----> 4 weight = client.get_measurements('Weight')

C:\Users\David\Anaconda3\lib\site-packages\myfitnesspal\client.py in get_measurements(self, measurement, lower_bound, upper_bound)
292
293 # remove entries that are not within the dates specified
--> 294 for date in measurements.keys():
295 if not upper_bound >= date >= lower_bound:
296 del measurements[date]

RuntimeError: OrderedDict mutated during iteration

Error in "import myfitnesspal"

Hi,

I can't seem to import the library in my Ubuntu.

Any idea?

$ uname -a
Linux jink 3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 15:31:16 UTC 2013 i686 i686 i386 GNU/Linux

$ python -i
Python 2.7.3 (default, Feb 27 2014, 20:00:17)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import myfitnesspal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/__init__.py", line 1, in <module>
    from myfitnesspal.client import Client
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/client.py", line 7, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/local/lib/python2.7/dist-packages/requests/utils.py", line 23, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/usr/local/lib/python2.7/dist-packages/requests/compat.py", line 7, in <module>
    from .packages import charade as chardet
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/__init__.py", line 16, in <module>
    from .connectionpool import (
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 12, in <module>
    from .util import resolve_cert_reqs, resolve_ssl_version, assert_fingerprint
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/__init__.py", line 18, in <module>
    from .timeout import (
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/timeout.py", line 4, in <module>
    from ..exceptions import TimeoutStateError
ImportError: cannot import name TimeoutStateError
>>>

IndexError in _get_goals

Hello @coddingtonbear,
I believe I found an issue when running _get_goals. I've copied my use case below, and substituted fake values for the username and password.

$ python
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import myfitnesspal
>>> client = myfitnesspal.Client("username", "password")
>>> day = client.get_date(2015, 4, 20)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "d:\Python27\lib\site-packages\myfitnesspal\client.py", line 209, in get_date
    goals = self._get_goals(document)
  File "d:\Python27\lib\site-packages\myfitnesspal\client.py", line 109, in _get_goals
    total_header = document.xpath("//tr[@class='total']")[0]
IndexError: list index out of range

I double checked the Food Diary for the given date (4/20/2105) and the source HTML does indeed have the total class defined just like your test cases.

<tr class="total">

    <td class="first">Totals</td>
        <td>1,297</td>
        <td>157</td>
        <td>39</td>
        <td>86</td>
        <td>20</td>
        <td>1,307</td>
    <td class="empty"></td>

</tr>

I will be glad to follow up with further information, or submit a potential fix for the issue myself ๐Ÿ˜ƒ

Looking forward to your response!

@bradgarropy

Add support for retrieving a filtered view of entries

Why

Sometimes, for analysis purposes, we want to extract a filtered view of a food log. For example, I want to be able to filter only those entries that correspond to sweets, that can be had at all meals. Or maybe I want to see how many bread-related products I am eating.

What

  • get_date method from Client receives filter as a parameter. It is a function which takes one parameter of type myfitnesspal.entry.Entry and returns True/False depending on whether the entry is added or not

Note

This is not exactly the ideal solution. The ideal solution is to make the Day / Meal / Entry structures mutable. However, for me that is too much work right now.

Changed page?

Been getting this lately. Command is myfitnesspal day $username:

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 329, in get_date
meals = self._get_meals(document)
File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/client.py", line 285, in _get_meals
value = self._get_numeric(column.text)
File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/client.py", line 215, in _get_numeric
return int(re.sub(r'[^\d.]+', '', string))
ValueError: invalid literal for int() with base 10: ''

Failed to install on Windows 7 with Python 3.4

This is a fantastic module to discover and I would really like to use it. Unfortunately I am noob when it comes to installing 3rd party software so I am not sure what went wrong (or how to describe it to you). As far as I can tell, I was missing lxml so I installed that but the "import lxml.html" line still failed. If you can tell me how to report my problems in a way you can follow then I will give you all the details you want.

Ben [email protected]

Unable to set authentication

I just finished installing the package using 'pip install myfitnesspal', but I am unable to store my password for authentication using 'myfitnesspal store-password my_username'. After I enter that command, I get ''. -bash: myfitnesspal: command not found'. Is there something else I need to install or do? Any help is greatly appreciated!

facebook login

I use facebook to login to myfitnesspal. As such, my account doesn't have a password, nor can I add one without disconnecting from facebook.

Is there/can there be a way to use python-myfitnesspal with facebook logins?

new error

Unable to fetch user metadata; this may cause Myfitnesspal to behave incorrectly if you have logged-in with your e-mail address rather than your basic username; status 504

my program was working last week so this is a new error


JSONDecodeError Traceback (most recent call last)
in
----> 1 client = myfitnesspal.Client('username_example')
2
3 Day = client.get_date(begin_year, begin_month, begin_day)
4 Date = str(today)
5

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in init(self, username, password, login, unit_aware)
56 self.session = requests.Session()
57 if login:
---> 58 self._login()
59
60 @Property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _login(self)
110
111 self._auth_data = self._get_auth_data()
--> 112 self._user_metadata = self._get_user_metadata()
113
114 # authenticity token required for measurement set function.

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_user_metadata(self)
161 )
162
--> 163 return result.json()['item']
164
165 def _get_full_name(self, raw_name):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py in json(self, **kwargs)
894 # used.
895 pass
--> 896 return complexjson.loads(self.text, **kwargs)
897
898 @Property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 parse_int is None and parse_float is None and
347 parse_constant is None and object_pairs_hook is None and not kw):
--> 348 return _default_decoder.decode(s)
349 if cls is None:
350 cls = JSONDecoder

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

dietary fiber in day.totals

Currently Day.totals returns a dict with keys Calories, carbs, fat, protein, sodium and sugar - which are availiable on https://www.myfitnesspal.com/food/diary/ page.
There are other fields myfitnesspal stores, like vitamin A, vitamin D, potassium, Dietary Fiber and others, which would be helpful to analyze, especially fiber intake in my opinion.
Any chance we could include it? Maybe by using data export premium feature?

The tool doesn't work on ubuntu out of the box

I just installed your tool and got an error:

ERROR:myfitnesspal.cmdline:No recommended backend was available
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 79, in store_password
    store_password_in_keyring(args.username, password)
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/keyring_utils.py", line 35, in store_password_in_keyring
    password,
  File "/usr/local/lib/python2.7/dist-packages/keyring/core.py", line 48, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/usr/local/lib/python2.7/dist-packages/keyring/backends/fail.py", line 18, in get_password
    raise RuntimeError("No recommended backend was available")
RuntimeError: No recommended backend was available
Traceback (most recent call last):
  File "/usr/local/bin/myfitnesspal", line 9, in <module>
    load_entry_point('myfitnesspal==1.8.0', '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 79, in store_password
    store_password_in_keyring(args.username, password)
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/keyring_utils.py", line 35, in store_password_in_keyring
    password,
  File "/usr/local/lib/python2.7/dist-packages/keyring/core.py", line 48, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/usr/local/lib/python2.7/dist-packages/keyring/backends/fail.py", line 18, in get_password
    raise RuntimeError("No recommended backend was available")
RuntimeError: No recommended backend was available

According to another ticket on github, it looks like something has been changed...
zalando-zmon/zmon-cli#10

Installing keyrings.alt solved my issue. So I guess this has to be added to the requirements.txt

get_exercise: invalid literal for int() with base 10: ''

When I attempt to use the get_exercise code, I get the following error.

>>> import myfitnesspal
>>> client = myfitnesspal.Client('********', '********')
>>> client.get_exercise(2017,9,1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "myfitnesspal\client.py", line 432, in get_exercise
    exercise = self._get_exercise(document)
  File "myfitnesspal\client.py", line 381, in _get_exercise
    value = self._get_numeric(column.text)
  File "myfitnesspal\client.py", line 220, in _get_numeric
    return int(re.sub(r'[^\d.]+', '', string))
ValueError: invalid literal for int() with base 10: ''

I believe it's related to the fact that my iPhone syncs my step data in and returns N/A for minutes, which means that the re.sub... in _get_numeric is returning an empty string to int()

I can fix this, but I already have a pull request open and I'm unsure semantically if it makes more sense to check in _get_numeric and return 0 for blank strings or whether the get_exercise should be parsing for entirely non-numeric content before calling _get_numeric

JSONDecodeError

Tried running in iPython Notebook & terminal .. same error:

import myfitnesspal

client = myfitnesspal.Client('wadatahaz')


JSONDecodeError Traceback (most recent call last)
in ()
1 import myfitnesspal
2
----> 3 client = myfitnesspal.Client('wadatahaz')

/Users/WTAYLO/anaconda/lib/python2.7/site-packages/myfitnesspal/client.pyc in init(self, username, password, login, unit_aware)
48 self.session = requests.Session()
49 if login:
---> 50 self._login()
51
52 @Property

/Users/WTAYLO/anaconda/lib/python2.7/site-packages/myfitnesspal/client.pyc in _login(self)
101 )
102
--> 103 self._auth_data = self._get_auth_data()
104 self._user_metadata = self._get_user_metadata()
105

/Users/WTAYLO/anaconda/lib/python2.7/site-packages/myfitnesspal/client.pyc in _get_auth_data(self)
119 )
120
--> 121 return result.json()
122
123 def _get_user_metadata(self):

/Users/WTAYLO/anaconda/lib/python2.7/site-packages/requests/models.pyc in json(self, *_kwargs)
761 # used.
762 pass
--> 763 return json.loads(self.text, *_kwargs)
764
765 @Property

/Users/WTAYLO/anaconda/lib/python2.7/site-packages/simplejson/init.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)
503 parse_constant is None and object_pairs_hook is None
504 and not use_decimal and not kw):
--> 505 return _default_decoder.decode(s)
506 if cls is None:
507 cls = JSONDecoder

/Users/WTAYLO/anaconda/lib/python2.7/site-packages/simplejson/decoder.pyc in decode(self, s, _w, _PY3)
368 if _PY3 and isinstance(s, binary_type):
369 s = s.decode(self.encoding)
--> 370 obj, end = self.raw_decode(s)
371 end = _w(s, end).end()
372 if end != len(s):

/Users/WTAYLO/anaconda/lib/python2.7/site-packages/simplejson/decoder.pyc in raw_decode(self, s, idx, _w, _PY3)
398 elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
399 idx += 3
--> 400 return self.scan_once(s, idx=_w(s, idx).end())

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

client.get_date() not working

Hi,
I have been using myfitnesspal package successfully for >9 months, I last used it 7 days ago with no problems.
Today when I use it, I get the following error:

day = client.get_date(2016, 3, 2)

Traceback (most recent call last):
File "<pyshell#0>", line 1, in
day = client.get_date(current_date)
File "C:\Python27\lib\site-packages\myfitnesspal\client.py", line 329, in get_date
meals = self._get_meals(document)
File "C:\Python27\lib\site-packages\myfitnesspal\client.py", line 285, in _get_meals
value = self._get_numeric(column.text)
File "C:\Python27\lib\site-packages\myfitnesspal\client.py", line 215, in _get_numeric
return int(re.sub(r'[^\d.]+', '', string))
ValueError: invalid literal for int() with base 10: ''

I have updated to the latest version (v1.8.2). I am using python v2.7.11
Any suggestions?

Requests strips out date parameter when fetching data

I found that I couldn't fetch any data from the anything other than the current day. It took a little while to figure out what was going on.

On my system (Ubuntu 13.10 64bit) the requests.get method seems to strip out extra parameters if called with a HTTPS url, as well as convert the url to non-HTTPS. My pythons-request package has version number 1.2.3, which matches that in requirements.txt.

Below output may make it clearer:
import requests
r = requests.get("http://www.myfitnesspal.com/food/diary/username?date=2013-06-11")
print r.url
http://www.myfitnesspal.com/food/diary/username?date=2013-06-11
r = requests.get("https://www.myfitnesspal.com/food/diary/username?date=2013-06-11")
print r.url
http://www.myfitnesspal.com/food/diary/username

If I set:
BASE_URL = 'http://www.myfitnesspal.com/'
BASE_URL_SECURE = 'https://www.myfitnesspal.com/'
and then use the secure one in _login and the standard one for other requests, it seems to work.

I'm not familiar enough with requests yet to know why this is happening.

Question about your API application

Hi, sorry to open an irrelevant issue, but I had a question as to how long it took you to get approved for MFP's API?

I just sent in my application yesterday, and I'm dyingggg to get approved.

Extra white space in 'totals' and 'goals'

There seems to have been a change on the myfitnesspal.com side that is adding \ncalories\n' to at least the goals and totals results. I was able to fix it locally by changing the following function in client.py:

def _get_full_name(self, raw_name):
name = raw_name.lower().strip()
if name not in self.ABBREVIATIONS:
return name
return self.ABBREVIATIONS[name]

I didn't want to go through creating a pull request for 8 characters, but thought it might be something that you could use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.