Advertisement
Guest User

Python Script Import TaskAnt tasks to Todoist

a guest
Nov 28th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import sys
  2. import json
  3. import time
  4. import os
  5. import urllib2
  6. import urllib
  7.  
  8. API_ROOT = "https://todoist.com/API/addItem"
  9. directory = '/home/fergus/Downloads/todo/fergus-backup-20141124/Personal/'
  10.  
  11. data = {'token': 'TOKEN'}
  12.  
  13. for filename in os.listdir(directory):
  14. with open(directory + filename) as f:
  15. try:
  16. jsondata = json.load(f)
  17. if int(jsondata['status']) == 1:
  18. print "Adding %s" % jsondata['description']
  19. data['content'] = jsondata['description']
  20. url_values = urllib.urlencode(data)
  21. full_url = API_ROOT + '?' + url_values
  22. urllib2.urlopen(full_url).read()
  23. except:
  24. print "Failed on %s" % filename
  25. print sys.exc_info()[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement