Python script to automatically fill Toggl Track with Anki reviews.
Properly configure the script as explained below, in particular the ALL_REVIEWS_FROM_DTIME
setting which lets the script know from when it should start exporting Anki Reviews.
If you want to export all your Anki reviews, just switch the year from 2023
to 1789
.
They didn't have Anki back then, so you should be good 😜
After the initial export, you can start using the script every day (or every week, or every month, or ...) after doing your Anki reviews to add new time entires in Toggl for your last Anki reviews.
If you feel fancy : Set up a scheduled task to run py anki2toggl.py
automatically for you every evening.
I haven't taken the time to implement something proper for the configuration (yet?)... So I'll have you open and edit the python script directly (using your favorite notepad application : Notepad, Notepad++, Visual Code, etc.).
However, even if you are not a developer, it shouldn't be too complicated as I have put everything in a very obvious location at the top of the file. It's goign to be very difficult to miss 😉 Just look for this :
Lines 12 to 23 in 602b146
Details
Variable | Description | ... |
---|---|---|
ANKI_PROFILE | Anki's profile from which you want to export the reviews Default: User 1 (Anki's default profile, if like me, you couldn't be bothered with modifying it) |
If you don't know, simply press Ctrl+Shift+P (or go to File > Switch Profile ) in Anki to find the list of profiles. |
ALL_REVIEWS_FROM_DTIME | Date/Time (in ISO format1) from which you want to export your Anki reviews. Default: 2023-01-01T00:00:00Z |
All your reviews after that date/time will be synchronized from Anki to Toggl. This date/time should only be useful for the very first synchronization. After that, it will only synchronize new Anki reviews. |
BATCHING_ANKI_REVIEWS _THRESHOLD_IN_SEC |
Interval of time (in seconds) between 2 card reviews for which those should be considered as part of the same "review session". Default: 120 (after testing, it seemed to produce the "better-looking" results in Toggl) |
Indeed, Anki reviews are "per card". However, you most probably don't want one time entry in Toggl for each card you reviewed. This setting allows you to batch multiple, yet close (in time), Anki card reviews into a single time entry in Toggl. If set to 0 , Anki card reviews won't get batched and will be exported as-is in Toggl. |
API_TOKEN | Your Toggl API token. | More info on where to find it here : https://support.toggl.com/en/articles/3116844-where-is-my-api-key-located |
WORKSPACE_NAME | Name of your Toggl workspace. | Can be found here : https://track.toggl.com/organization/workspaces |
PROJECT_NAME | Name of the Toggl project in which the time entry will be added. Default: Priming (Following Refold's recommendation2) |
Can be found here : https://track.toggl.com/projects/ The project should have been previously created in Toggl. |
TIME_ENTRY_DESCRIPTION | Description of the created time entries. Default: Anki Review (Following Refold's recommendation2) |
Right-click > "Save link as..." : anki2toggl.py
The first (obvious) step is to download and install Python.
You can find that here : https://www.python.org/ > "Downloads"
Once the installation is over, open a command prompt (Win+R
> type 'cmd' > Enter
) and use the following command to verify the version :
py --version"
(The script was tested with Python 3.11.3, so anything greater than or equal to that should work fine.)
After that, you will most probably need to install some dependencies:
py -m pip install requests
And finally... Run it:
cd C:\path\where\you\downloaded\the\py\script\
py anki2toggl.py
The script needs Anki to be closed to access the card reviews in Anki's database.
Verify your Toggl API Token is properly configured.
- Turn that Anki2Toggl script into an Anki addon, which would simply run when closing Anki (similarly to the Anki synchronization with AnkiWeb)
- See if I can contribute to the asbplayer project to auto-start/stop a time entry in Toggl
Footnotes
-
More info on the ISO 8601: https://en.wikipedia.org/wiki/ISO_8601 ↩
-
Refold's video on time tracking with Toggl: https://www.youtube.com/watch?v=dm6RYK9J61k ↩ ↩2