Skip to content

Instantly share code, notes, and snippets.

@rud
Created July 15, 2010 12:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rud/476889 to your computer and use it in GitHub Desktop.
Save rud/476889 to your computer and use it in GitHub Desktop.
Tool for migrating tasks to The Hit List from Remember The Milk
# 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
@betobetico
Copy link

Hi.

I'm getting the following error were executing the file:

/opt/local/lib/ruby/1.8/net/http.rb:586:in connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) from /opt/local/lib/ruby/1.8/net/http.rb:586:inconnect'
from /opt/local/lib/ruby/1.8/net/http.rb:553:in do_start' from /opt/local/lib/ruby/1.8/net/http.rb:542:instart'
from /opt/local/lib/ruby/1.8/open-uri.rb:242:in open_http' from /opt/local/lib/ruby/1.8/open-uri.rb:616:inbuffer_open'
from /opt/local/lib/ruby/1.8/open-uri.rb:164:in open_loop' from /opt/local/lib/ruby/1.8/open-uri.rb:162:incatch'
from /opt/local/lib/ruby/1.8/open-uri.rb:162:in open_loop' from /opt/local/lib/ruby/1.8/open-uri.rb:132:inopen_uri'
from /opt/local/lib/ruby/1.8/open-uri.rb:518:in open' from /opt/local/lib/ruby/1.8/open-uri.rb:30:inopen'
from milk-extract.rb:27

Do you know why? can you help me?

Thanks

@rud
Copy link
Author

rud commented Feb 15, 2011

Hi betobetico,

What ruby version are you using? I just tried the script again with: ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0], no problem. I see something similar reported here [1], so I think an upgrade might help.

[1] http://www.ruby-forum.com/topic/129530

Regards
/Laust

@rud
Copy link
Author

rud commented Feb 16, 2011

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment