coddingtonbear / python-myfitnesspal

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

Enable access to friends exercise data #139

Closed jwhitbread closed 11 months ago

jwhitbread commented 2 years ago

Simple change to allow the viewing of friend's exercises. I noticed that no matter what username you pass in it will default to self.effective_username. I've just made it so it will pass the username into _get_exercises from the kwargs so it can be used in _get_url_for_exercise.

So now I can do:

friend = client.get_date(2022, 4, 12, username="friend_username")
friend.exercises[n].get_as_list()

and it'll return the friend's data and not my own.

hannahburkhardt commented 2 years ago

If the person doesn't have their diary shared with me, we currently return nothing. It might be good to print the warning that mfp returns. e.g. document.find_class('main-title')[0].text is "This Exercise Diary is Private" when I tested it with someone who's my friend, but who has their diary settings set to "private".