Created
October 19, 2016 19:09
-
-
Save sincarne/706764c83a218047aaa32524b1ccf1b1 to your computer and use it in GitHub Desktop.
Turn Trello cards into Habitica tasks; remove cards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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