Skip to content

Instantly share code, notes, and snippets.

@stengland
Last active September 29, 2015 08:47
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 stengland/60c08a602231f4960709 to your computer and use it in GitHub Desktop.
Save stengland/60c08a602231f4960709 to your computer and use it in GitHub Desktop.
Convert wunderlist tasks to todo.txt file
#!/usr/bin/env ruby
require 'json'
require 'date'
wunderlist = JSON.parse(File.read ARGV[0])
tasks, lists = wunderlist['data']["tasks"], wunderlist['data']["lists"]
tasks.map! do |task|
due_date = task["due_date"]
completed_at = Date.parse(task["completed_at"]).strftime if task["completed_at"]
list = lists.detect { |l| l['id'] == task['list_id'] }
project_title = (list ? list['title'] : 'inbox').split(' ').map(&:capitalize).join
completed = "x #{completed_at} " if completed_at
title = task['title']
project = "+#{project_title}"
note = "- #{task['note'].gsub("\n", " ")}" if task['note']
due = "due:#{due_date}" if due_date
recurrence = "rec:#{task['recurrence_count']}#{task['recurrence_type'][0]}" if task['recurrence_type']
[completed, title, note, project, due, recurrence].compact.join(' ').squeeze(' ')
end
puts tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment