Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import json
- import time
- import os
- import urllib2
- import urllib
- API_ROOT = "https://todoist.com/API/addItem"
- directory = '/home/fergus/Downloads/todo/fergus-backup-20141124/Personal/'
- data = {'token': 'TOKEN'}
- for filename in os.listdir(directory):
- with open(directory + filename) as f:
- try:
- jsondata = json.load(f)
- if int(jsondata['status']) == 1:
- print "Adding %s" % jsondata['description']
- data['content'] = jsondata['description']
- url_values = urllib.urlencode(data)
- full_url = API_ROOT + '?' + url_values
- urllib2.urlopen(full_url).read()
- except:
- print "Failed on %s" % filename
- print sys.exc_info()[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement