Skip to content

Instantly share code, notes, and snippets.

@sincarne
Created October 19, 2016 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sincarne/706764c83a218047aaa32524b1ccf1b1 to your computer and use it in GitHub Desktop.
Save sincarne/706764c83a218047aaa32524b1ccf1b1 to your computer and use it in GitHub Desktop.
Turn Trello cards into Habitica tasks; remove cards
#!/usr/bin/python
# requires trello, requests, available through pip
from trello import TrelloApi
import json, os, requests, subprocess
HABITICA_USER = os.getenv('HAB_API_USER', '')
HABITICA_KEY = os.getenv('HAB_API_TOKEN', '')
TRELLO_KEY = os.getenv('TRELLO_API_KEY', '')
TRELLO_TOKEN = os.getenv('TRELLO_API_TOKEN', '')
TRELLO_BOARD = os.getenv('TRELLO_API_BOARD', '')
headers = {"x-api-key":HABITICA_KEY,"x-api-user":HABITICA_USER,"Content-Type":"application/json"}
trello = TrelloApi(TRELLO_KEY, token=TRELLO_TOKEN)
results = trello.lists.get_card(TRELLO_BOARD)
for card in results:
task = {
"type" : "todo",
"text" : card['name'],
"notes" : card['id']
}
req = requests.post("https://habitica.com/api/v3/tasks/user", headers=headers, data=json.dumps(task))
trello.cards.delete(card['id'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment