adium2gmail 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -1
- data/adium2gmail.gemspec +1 -1
- data/bin/adium2gmail +42 -6
- data/lib/adium2gmail.rb +39 -17
- data/lib/adium2gmail/version.rb +1 -1
- metadata +11 -11
data/README.md
CHANGED
@@ -16,6 +16,10 @@ Run:
|
|
16
16
|
|
17
17
|
Open the file in Thunderbird to view all the chatlogs
|
18
18
|
|
19
|
+
Copy it into your gmail
|
20
|
+
|
21
|
+

|
22
|
+
|
19
23
|
## TODO
|
20
24
|
|
21
25
|
1. Multiprocessing of chatlogs to improve performance
|
@@ -27,4 +31,4 @@ Open the file in Thunderbird to view all the chatlogs
|
|
27
31
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
32
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
29
33
|
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
-
5. Create new Pull Request
|
34
|
+
5. Create new Pull Request
|
data/adium2gmail.gemspec
CHANGED
data/bin/adium2gmail
CHANGED
@@ -2,12 +2,48 @@
|
|
2
2
|
|
3
3
|
require 'adium2gmail'
|
4
4
|
require 'Find'
|
5
|
-
require '
|
5
|
+
require 'optparse'
|
6
|
+
require 'ostruct'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
options = OpenStruct.new
|
10
|
+
options.input_path = File.expand_path('~/Library/Application Support/Adium 2.0/Users/Default/Logs')
|
11
|
+
options.output_path = "chatlogs"
|
12
|
+
options.parallel = false
|
13
|
+
|
14
|
+
opts = OptionParser.new do |opts|
|
15
|
+
opts.banner = "Usage: adium2gmail [options]"
|
16
|
+
|
17
|
+
opts.separator ""
|
18
|
+
opts.separator "Specific options:"
|
19
|
+
|
20
|
+
opts.on("-i", "--input [PATH]", "Path of the adium chatlogs") do |input_path|
|
21
|
+
options.input_path = input_path
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on("-o", "--output [PATH]", "Path of the output path") do |output_path|
|
25
|
+
options.output_path = output_path
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-p", "--[no-]parallel", "Enable parallel processing (experimental!)") do |parallel|
|
29
|
+
options.parallel = parallel
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.separator ""
|
33
|
+
opts.separator "Common options:"
|
34
|
+
|
35
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
36
|
+
puts opts
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on_tail("--version", "Show version") do
|
41
|
+
puts Adium2Gmail::VERSION
|
42
|
+
exit
|
43
|
+
end
|
11
44
|
end
|
12
45
|
|
13
|
-
|
46
|
+
opts.parse!(ARGV)
|
47
|
+
|
48
|
+
|
49
|
+
Adium2Gmail::process_adium_chatlogs options.input_path, options.output_path, options.parallel
|
data/lib/adium2gmail.rb
CHANGED
@@ -4,6 +4,8 @@ require 'find'
|
|
4
4
|
require 'logger'
|
5
5
|
require 'mail'
|
6
6
|
require 'nokogiri'
|
7
|
+
require 'ostruct'
|
8
|
+
require 'parallel'
|
7
9
|
|
8
10
|
|
9
11
|
module Adium2Gmail
|
@@ -21,19 +23,19 @@ module Adium2Gmail
|
|
21
23
|
content_type 'text/html; charset=UTF-8'
|
22
24
|
body email_body
|
23
25
|
end
|
24
|
-
header = "From - " + chat_date.strftime("%a %b %d %H:%M:%S %Y")
|
25
|
-
header += "Date: " + chat_date.strftime("%a, %d %b %Y %H:%M:%S %z")
|
26
|
-
header +
|
26
|
+
header = "From - " + chat_date.strftime("%a %b %d %H:%M:%S %Y\n")
|
27
|
+
header += "Date: " + chat_date.strftime("%a, %d %b %Y %H:%M:%S %z\n")
|
28
|
+
header + mail.to_s.split("\n")[1..-1].join("\n") + "\n\n\n"
|
27
29
|
end
|
28
30
|
|
29
31
|
def self.get_email_body(f)
|
30
32
|
messages = ''
|
31
|
-
|
33
|
+
|
32
34
|
doc = Nokogiri::XML(File.open(f, "r"))
|
33
|
-
|
35
|
+
|
34
36
|
doc.remove_namespaces! #stupid namespaces
|
35
37
|
|
36
|
-
doc.xpath("//message").each do |
|
38
|
+
doc.xpath("//message").each do |message|
|
37
39
|
datetime = DateTime.parse(message.xpath("@time").text)
|
38
40
|
nickname = message.xpath("@alias").text
|
39
41
|
nickname = message.xpath("@sender").text if nickname.blank?
|
@@ -48,7 +50,7 @@ module Adium2Gmail
|
|
48
50
|
time = date.strftime("%I:%M %p")
|
49
51
|
|
50
52
|
message_tag = message_tag.xpath("div/span")
|
51
|
-
|
53
|
+
|
52
54
|
#Not sure why I do the gsub here. I did it in python but didn't comment :(
|
53
55
|
#But I'm sure I did it for a good reason
|
54
56
|
message = message_tag.text.gsub("'", "'")
|
@@ -66,17 +68,37 @@ module Adium2Gmail
|
|
66
68
|
</div>}
|
67
69
|
end
|
68
70
|
|
69
|
-
def self.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
def self.find_logs(input)
|
72
|
+
infos = []
|
73
|
+
Find.find(input) do |f|
|
74
|
+
if f.match(/\.chatlog.*?\.xml\Z/) && !f.include?("msn chat") #skipping multiple conversations for now
|
75
|
+
to_email = File.basename(File.dirname(File.dirname(File.dirname(f)))).sub(/.*?\./, "") #this is somewhat hacky...
|
76
|
+
from_email, chat_date = File.basename(f, ".xml").split()
|
77
|
+
chat_date = DateTime.parse(chat_date.gsub!(".", ":"))
|
78
|
+
|
79
|
+
info = OpenStruct.new
|
80
|
+
info.from_email = from_email
|
81
|
+
info.to_email = to_email
|
82
|
+
info.f = f
|
83
|
+
info.chat_date = chat_date
|
84
|
+
infos.push info
|
85
|
+
end
|
86
|
+
end
|
76
87
|
|
77
|
-
|
88
|
+
return infos
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.process_adium_chatlogs(input, output_path, parallel)
|
92
|
+
File.open output_path, "w" do |output_file|
|
93
|
+
if parallel then
|
94
|
+
Parallel.map(find_logs(input)) do |info|
|
95
|
+
output_file.puts create_email(info.from_email, info.to_email, info.f, info.chat_date)
|
78
96
|
end
|
79
|
-
|
97
|
+
else
|
98
|
+
find_logs(input).each do |info|
|
99
|
+
output_file.puts create_email(info.from_email, info.to_email, info.f, info.chat_date)
|
100
|
+
end
|
101
|
+
end
|
80
102
|
end
|
81
|
-
end
|
103
|
+
end
|
82
104
|
end
|
data/lib/adium2gmail/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adium2gmail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
16
|
-
requirement: &
|
16
|
+
requirement: &70157516174440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70157516174440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &70157516173400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70157516173400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: parallel
|
38
|
+
requirement: &70157516172380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70157516172380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70157516171940 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70157516171940
|
58
58
|
description: Converts Adium chatlogs to emails
|
59
59
|
email:
|
60
60
|
- johnjiang101@gmail.com
|