Last active
September 29, 2015 08:47
-
-
Save stengland/60c08a602231f4960709 to your computer and use it in GitHub Desktop.
Convert wunderlist tasks to todo.txt file
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/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