Created
July 15, 2010 12:52
-
-
Save rud/476889 to your computer and use it in GitHub Desktop.
Tool for migrating tasks to The Hit List from Remember The Milk
This file contains 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
# Simple script for reading all tasks from Remember The Milk and exporting them in a format usable | |
# with The Hit List. | |
# | |
# Migrating from http://www.rememberthemilk.com to http://www.potionfactory.com/thehitlist | |
# | |
# Create a config.yml file in the same folder, then simply run it with "ruby milk-extract.rb" | |
# | |
# Released under MIT License | |
# | |
# Written by Laust Rud Jacobsen, rud@personal-it.dk, 2010 | |
require 'rubygems' | |
gem 'nokogiri' | |
require "nokogiri" | |
require "open-uri" | |
require 'yaml' | |
# Config file contents: | |
# username: rtm-user | |
# password: rtm-password | |
config = YAML.load_file('config.yml') | |
source = "https://www.rememberthemilk.com/atom/#{config['username']}/" | |
atom_feed = open(source, :http_basic_authentication => [config['username'], config['password']]) | |
class TodoItem < Struct.new(:title, :tags, :list, :notes); end | |
doc = Nokogiri::XML(atom_feed, 'UTF-8') | |
# puts doc | |
items = doc.css('entry').collect do |entry| | |
item = TodoItem.new | |
item.title = entry.css('title').first.content | |
item.tags = entry.css('.rtm_tags .rtm_tags_value').first.content.split(', ') | |
item.list = entry.css('.rtm_list .rtm_list_value').first.content | |
entry.css('.rtm_notes .rtm_note').each do |note| | |
title = note.css('.rtm_note_title').first.content | |
body = note.css('.rtm_note_content').first.content | |
(item.notes ||= []) << { :title => title, :body => body } | |
end | |
item | |
end | |
grouped_items = items.group_by(&:list) | |
grouped_items.each_pair do |heading, items| | |
puts "\n\nList: #{heading}" | |
items.each do |item| | |
tags = item.tags.reject {|tag| tag == 'none' }.collect { |tag| "/#{tag}/"}.join(' ') | |
notes = unless item.notes.nil? || item.notes.empty? | |
item.notes.collect {|note| [note[:title], note[:body]].compact.join(' - ') }.join(' | ') | |
end | |
puts " #{item.title} #{notes} #{tags}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
betobetico found a simple way of avoiding the error: switch from https to http in the url. Depending on the importance of the data you access with this, you might be all right. I'd still recommend upgrading ruby instead, though.