InsightTimer.com - API python script (meditation tracking)

I saw on the API page that someone wrote a script to copy meditation data from InsightTimer.com to Beeminder.

It only posted whether or not you meditated, not how many minutes you meditated for, so it was unsuitable if your goal was to increase the duration of meditation sessions as well as the frequency.

Anyway, I created a fork on github that does exactly that. Posting it here for posterity.

Please enjoy, peace be upon you and all that stuff…

7 Likes

I’ve tried everything, but I can’t seem to get this to work. My error message is:
2016-01-14 01:46:42,139 - main - DEBUG - Reading config file config.ini
2016-01-14 01:52:08,024 - main - DEBUG - Reading config file config.ini
2016-01-14 01:59:09,183 - main - DEBUG - Reading config file config.ini
2016-01-14 02:03:59,603 - main - DEBUG - Reading config file config.ini
2016-01-14 02:05:05,181 - main - DEBUG - Reading config file config.ini

I think I need a bit of a walk through. I want this goal so bad.

If that’s where it’s getting hung up, it’s probably unable to find or read the “config.ini” file.

Make sure that you’ve:

a) Renamed the default file from “default-config” to just "config"
b) Placed it in the same directory as the script itself
c) Populated all of the required data in the config file

1 Like

saved it as config (.ini),
double checked all my info,
it’s in the same folder; I still get:

2016-01-14 02:21:46,266 - main - DEBUG - Reading config file config.ini

I didn’t include stack trace logging in the script so if it’s falling down somewhere not obvious it won’t appear in the generated log.

Good news is you can see the error causing the problems with the following steps:

  • Create a new text file called “run-beesight.bat”
  • Copy the following inside and save it:

C:
C:~path to python.exe~\python.exe "C:~path to script file~\beesight.py"
pause

  • When you execute the .bat file you just made it will try to run the script and when it fails you’ll see the error message in the command prompt window. Let me know what it says…
1 Like

It prompts me to press a key and then it closes the window instantly.
Here is my file structure:

Ohhhh I see the problem. You just filled out the config file incorrectly. Here’s a sample of what it should look like:

[insight]
username=blahblahblah@gmail.com
password=iweufhsalfhsad

[beeminder]
username=bluremi
auth_token=RMrvzv4XMp2J63vBp9R4
goal_name=MeditationDaily

PS that’s not my real auth token

1 Like

Well I fixed that, the message is this now:

2016-01-14 02:40:52,633 - main - DEBUG - Submitting POST request to insighttimer.com
2016-01-14 02:40:58,342 - main - DEBUG - Submitting GET request to insighttimer.com
2016-01-14 02:40:58,604 - main - INFO - Parsing last four sessions from CSV:

It’s falling down as it’s trying to read your insighttimer session info.

Have you logged in to insighttimer and checked that you have sessions actually recorded?

1 Like

I just did some test batches.

Should the export link be this: https://insighttimer.com/sessions/export ?

1 Like

Yeah that’s right.

Run that .bat file again and when it tells you to “press any key to continue” scroll up and read the error messages instead of hitting the key to close the window.

1 Like

You have to replace the ~path to *****~ bits with the actual file path. I don’t know where you put the files on your computer so it’s expected that you fill that part in yourself.

In that .bat file you made, you just copied what I posted, but you were supposed to replace the two parts where it says ~path to python.exe~ and ~path to script file~ with the actual path in your computer.

For example, it should say something like C:\users\bluremi\python\python.exe, or at least that’s what it says on my computer because that’s where I installed it.

That’s why the .bat file script isn’t working for you.

Actually I should be thanking you, for pointing out to me that the folks at insighttimer.com just updated their website and the URL I’ve been using (which worked until yesterday!) is no longer valid.

I’ve uploaded a new script to github to fix the problem, it should work now.

1 Like

Glad I could “help”.

Now I get this:
2016-01-14 03:25:52,012 - main - INFO - Parsing last four sessions from CSV:
2016-01-14 03:25:52,013 - main - INFO - 01/14/2016 02:53:29 : 1 minutes
2016-01-14 03:25:52,014 - main - INFO - 01/14/2016 01:51:32 : 1 minutes
2016-01-14 03:25:52,014 - main - INFO - 01/13/2016 07:25:16 : 3 minutes

but nothing posts to beeminder.

Oh, I think it’s because you only have three sessions logged and the script expects you to have at least four.

If you log another test session for a total of four it should start working as expected.

Four was an arbitrary number, in a future version I will update it so it doesn’t break if there are fewer sessions than expected.

1 Like

Now I get this:
2016-01-14 04:12:04,170 - main - DEBUG - Submitting GET request to insighttimer.com
2016-01-14 04:12:04,511 - main - INFO - Parsing last four sessions from CSV:
2016-01-14 04:12:04,512 - main - INFO - 01/13/2016 14:12:17 : 1 minutes
2016-01-14 04:12:04,512 - main - INFO - 01/13/2016 14:07:26 : 1 minutes
2016-01-14 04:12:04,512 - main - INFO - 01/13/2016 12:53:29 : 1 minutes
2016-01-14 04:12:04,513 - main - INFO - 01/13/2016 11:51:32 : 1 minutes
2016-01-14 04:12:04,513 - main - INFO - No minutes logged for today’s date on InsightTimer.com

Still nothing posts to beeminder.

IT FINALLY WORKED.

Thanks for your help.

1 Like

Thanks for the script! When the logs are downloaded, the timezone is assumed to be US/Eastern. This may surprise you if you are meditating in a different timezone around midnight eastern. I’ll modify the script in a bit to add a timezone option in the config.

1 Like

Thanks, that’s great. I merged your fork and fixed the bug Dan ran into where he had not enough session data.

3 Likes