drmfinlay / todoist-org-mode

Convert Todoist projects into Org mode files
MIT License
14 stars 1 forks source link
emacs org-mode python todoist todoist-api

todoist-org-mode

Convert Todoist projects into Org mode files

What this project does

This is a Python language <https://www.python.org/> project with code to retrieve Todoist projects, sections and items using the Todoist Sync API (v9) <https://developer.todoist.com/sync/v9> and convert them into Org mode headings to be written to files.

Todoist <https://todoist.com/> is an application for maintaining to-do lists and planning projects. Org mode <https://orgmode.org/> is a GNU Emacs <https://www.gnu.org/software/emacs/>__ major mode for convenient plain text markup and much more, including maintaining to-do lists and planning projects.

todoist-org-mode Python files:

No part of this project modifies remote Todoist user data, it is only retrieved and converted locally.

Dependencies

Using this project

To use this project, follow the steps below.

. Clone or download and extract the repository.

.. code:: shell

  git clone https://github.com/drmfinlay/todoist-org-mode.git

. Open a command prompt or terminal in the repository's root directory.

.. code:: shell

  cd todoist-org-mode

. Install the required dependencies.

.. code:: shell

  pip install -r requirements.txt

todoist2org_convert program usage


Run ``todoist2org_convert``, passing your Todoist API token and an optional output
file path as the arguments. Your API token can be found under Settings->Integrations.

.. code:: shell

   # Either convert and print all headings to stdout.
   python todoist2org_convert.py 0123456789abcdef0123456789abcdef01234567

   # Or convert and write all headings to output.org.
   python todoist2org_convert.py 0123456789abcdef0123456789abcdef01234567 -o output.org

``todoist2org`` library usage

The todoist2org library can be used for custom conversion of Todoist projects, sections and/or items. For example, it could be used to convert all items in the special Inbox project and write an Inbox.org file:

.. code:: Python

import todoist2org

Use the API token to sync user resources.

api_token = "0123456789abcdef0123456789abcdef01234567" state = todoist2org.sync_todoist_state(api_token)

Assume the API request was successful and the Inbox project is first.

project = state["projects"][0] project_id = project["id"]

Write an Org mode file header followed by each generated heading to Inbox.org.

with open("Inbox.org", "w") as f: for line in todoist2org.generate_file_header(state, "Inbox"): f.write(line + "\n") f.write("\n") for heading in todoist2org.generate_project_headings(state, project_id, False): f.write(heading + "\n")

Limitations

License

This is free software licensed under the MIT licence.