Created
March 22, 2009 13:03
-
-
Save tdtds/83156 to your computer and use it in GitHub Desktop.
yoosee作mixi2gmailのバグfix差分
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
--- mixi2gmail.rb.20080404 2008-04-08 11:17:42.000000000 +0900 | |
+++ mixi2gmail.rb 2009-03-22 14:11:33.000000000 +0900 | |
@@ -34,7 +34,14 @@ | |
rescue LoadError | |
end | |
require 'nkf' | |
+ | |
require 'mechanize' | |
+require 'hpricot' | |
+begin | |
+ WWW::Mechanize.html_parser = Hpricot | |
+rescue NoMethodError | |
+end | |
+ | |
require 'net/smtp' | |
require 'time' | |
require 'optparse' | |
@@ -114,7 +121,7 @@ | |
@imagesrcs = Array.new | |
# pick up images from diary (standard image upload) | |
dbody.search("//div[@class='diaryPhoto']//td") do |i| | |
- @imagepages.push i.at("a")['onclick'].gsub(/MM_openBrWindow\('/, '').gsub(/'.+/, '') | |
+ @imagepages.push i.at("a")['onClick'].gsub(/MM_openBrWindow\('/, '').gsub(/'.+/, '') | |
a = i.at("a") | |
@imagesrcs.push a.at("img")['src'].gsub(/.+\//, "").gsub(/s\.jpg/, '.jpg') | |
end | |
@@ -134,7 +141,7 @@ | |
body = dbody.search("//div[@id='diary_body']").inner_html | |
unless title.empty? | |
- enc = ENV['LANG'] =~ /euc-jp/i ? 'e' : 'w' | |
+ enc = ENV['LANG'] =~ /euc/i ? 'e' : 'w' | |
puts NKF.nkf("-#{enc}", " + #{author}: #{title} (#{date} #{time})") | |
else | |
puts " + failed to parse diary of #{author}" | |
@@ -317,8 +324,9 @@ | |
content = '' | |
tmp = text | |
text = "--#{boundary}\n" | |
- text << "Content-Type: text/html;\n\n" | |
- text << tmp | |
+ text << "Content-Type: text/html; charset=EUC-JP\n" | |
+ text << "Content-Transfer-Encoding: base64\n\n" | |
+ text << [tmp].pack('m') | |
text << "\n\n" | |
unless images.empty? | |
@@ -348,8 +356,6 @@ | |
Date: #{datetime.rfc2822} | |
MIME-Version: 1.0 | |
X-ML-Name: mixi | |
-Content-Type: text/plain; charset=\"iso-2022-jp\" | |
-Content-Transfer-Encoding: 7bit | |
#{header} | |
#{NKF.nkf('-j',text)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment