im_exporter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/bin/im_exporter +56 -0
- data/im_porter.gemspec +28 -0
- data/lib/im_exporter.rb +4 -0
- data/lib/im_exporter/attachment.rb +18 -0
- data/lib/im_exporter/contact.rb +24 -0
- data/lib/im_exporter/message.rb +25 -0
- data/lib/im_exporter/version.rb +3 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54c525e62df78cbf60f8c476c7081d74cae9533d
|
4
|
+
data.tar.gz: fafbe187fe970ad7b181997f268764d049d1607e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3dcbfcc2eb10a56d98fa0bd135592158f887407886d2c3979107d7d5fd68d9ea0b2f3147e2f57785725b60ed505c9ccbf2367f521895705eb13762d4601b89b5
|
7
|
+
data.tar.gz: f2aa81f00d657db4e2974ee1e93d6d04e13fd69785ee4a9e8ca317159c8e44ba1eb8b7a1d823155ad5a2971733ed7d39326f1e012ee2da2ca00c006163b30028
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Ben Visser
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# im_exporter CLI
|
2
|
+
|
3
|
+
im_porter is an **iM**esasge **exporter** that backs up iMessage conversations to PDF or TXT files for easy reading and search
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install from the command line via
|
8
|
+
|
9
|
+
$ gem install im_exporter
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```im_exporter export --format PDF```
|
14
|
+
|
15
|
+
will output iMessage conversations in PDF documents in the pwd
|
16
|
+
|
17
|
+
## TODO
|
18
|
+
|
19
|
+
1. format PDF messages nicely so they look like a real iMessage conversation
|
20
|
+
2. refactor code so it doesn't look like complete shit
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
Copyright (C) 2015 Ben Visser
|
25
|
+
|
26
|
+
Released under the MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/im_exporter
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'im_exporter'
|
4
|
+
|
5
|
+
require 'commander/import'
|
6
|
+
require 'sqlite3'
|
7
|
+
require 'prawn'
|
8
|
+
require 'etc'
|
9
|
+
|
10
|
+
program :name, "iMessage Exporter CLI"
|
11
|
+
program :version, IM_Exporter::VERSION
|
12
|
+
program :description, 'Exports iMessage conversations as TEXT or PDF files'
|
13
|
+
program :help, 'Authors', 'Ben Visser <theodore.r.visser@gmail.com>'
|
14
|
+
program :help, 'Website', 'https://github.com/noqcks/im_exporter'
|
15
|
+
default_command :help
|
16
|
+
|
17
|
+
$chat_db = SQLite3::Database.new "/Users/#{Etc.getlogin}/Library/Messages/chat.db"
|
18
|
+
$user_db = SQLite3::Database.new "/Users/#{Etc.getlogin}/Library/Application Support/AddressBook/AddressBook-v22.abcddb"
|
19
|
+
|
20
|
+
command :export do |c|
|
21
|
+
c.syntax = 'export [options]'
|
22
|
+
c.description = 'Begin the export of iMessages into a desired format'
|
23
|
+
c.option '-f', '--format STRING', String, 'The type of format you want the iMessages outputted to [PDF, TXT]'
|
24
|
+
c.action do |args, options|
|
25
|
+
options.default :format => 'PDF'
|
26
|
+
|
27
|
+
contact = IM_Exporter::Contact
|
28
|
+
message = IM_Exporter::Message
|
29
|
+
attachment = IM_Exporter::Attachment
|
30
|
+
|
31
|
+
contact.get_contact_ids.each do |contact_row|
|
32
|
+
$pdf = Prawn::Document.new if options.format.eql? 'PDF'
|
33
|
+
id = contact_row[0]
|
34
|
+
phone = contact_row[1].delete '+'
|
35
|
+
contact_name = contact.name(id, phone)
|
36
|
+
messages = 0
|
37
|
+
message.read(id).each do |message_row|
|
38
|
+
messages += 1
|
39
|
+
if message.is_an_attachment?(message_row[2])
|
40
|
+
attachment.write(message_row[3]) if options.format.eql? 'PDF'
|
41
|
+
else
|
42
|
+
if message.is_from_me?(message_row[0])
|
43
|
+
message.write("me", message_row[1], contact_name, options.format)
|
44
|
+
else
|
45
|
+
message.write(contact_name, message_row[1], contact_name, options.format)
|
46
|
+
end
|
47
|
+
end if message_row[4].nil?
|
48
|
+
end
|
49
|
+
if options.format.eql? 'PDF'
|
50
|
+
$pdf.render_file "#{contact_name}.pdf" unless messages.eql? 0
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
data/im_porter.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'im_exporter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "im_exporter"
|
8
|
+
spec.version = IM_Exporter::VERSION
|
9
|
+
spec.authors = ["Ben Visser"]
|
10
|
+
spec.email = ["theodore.r.visser@gmail.com"]
|
11
|
+
spec.summary = %q{iMessage Exporter}
|
12
|
+
spec.description = %q{Export iMessage conversations into TXT or PDF files}
|
13
|
+
spec.homepage = "https://github.com/noqcks/im_exporter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["im_exporter"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'commander', '~> 4.3', '>= 4.3.3'
|
22
|
+
spec.add_runtime_dependency 'sqlite3', '~> 1.3.10', '>= 1.3.10'
|
23
|
+
spec.add_runtime_dependency 'prawn', '~> 2.0.1', '>= 2.0.1'
|
24
|
+
spec.add_runtime_dependency 'etc', '~> 0.2.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
end
|
data/lib/im_exporter.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module IM_Exporter
|
2
|
+
module Attachment
|
3
|
+
def self.write(attachment_id)
|
4
|
+
$chat_db.execute('select a.filename from attachment as a join message as m on m.date = a.created_date where m.rowid=?', attachment_id) do |file_dir|
|
5
|
+
file = file_dir.join('').sub!('~', '/Users/benvisser')
|
6
|
+
if self.supported_file_type?(file)
|
7
|
+
$pdf.image file, :height => 250
|
8
|
+
else
|
9
|
+
$pdf.text "[IMAGE-TYPE NOT SUPPORTED]"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.supported_file_type?(file)
|
15
|
+
(file.include? "JPG" or file.include? "PNG") ? true : false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module IM_Exporter
|
2
|
+
module Contact
|
3
|
+
def self.parse_contact_name_from_string(row)
|
4
|
+
return row.select{|element| row.count(element) > 1 }.uniq.select{ |i| i[/[a-zA-Z]/] }.join(' ')
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.name(id, phone)
|
8
|
+
name = id
|
9
|
+
$user_db.execute('select ZSTRINGFORINDEXING from ZABCDCONTACTINDEX') do |contact|
|
10
|
+
row = contact.join('').split(' ')
|
11
|
+
contact_name = self.parse_contact_name_from_string(row)
|
12
|
+
contact_phone = row.last
|
13
|
+
if contact_phone.eql? phone
|
14
|
+
name = contact_name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
return name
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get_contact_ids
|
21
|
+
return $chat_db.execute('select ROWID, id from handle')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module IM_Exporter
|
2
|
+
module Message
|
3
|
+
def self.write(user, message, file_name, type)
|
4
|
+
if type.eql? 'PDF'
|
5
|
+
$pdf.font("/Library/Fonts/Times New Roman.ttf") do
|
6
|
+
$pdf.text "#{user}: #{message}"
|
7
|
+
end
|
8
|
+
else
|
9
|
+
File.open("#{file_name}.txt", 'a') {|f| f.write("#{user}: #{message}\n") }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.read(id)
|
14
|
+
return $chat_db.execute("select is_from_me, text, cache_has_attachments, rowid, cache_roomnames from message where handle_id= ?", id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.is_from_me?(message)
|
18
|
+
(message === 1) ? true : false
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.is_an_attachment?(message)
|
22
|
+
(message === 1) ? true : false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: im_exporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Visser
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.3.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.3.3
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sqlite3
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.3.10
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.3.10
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.3.10
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.3.10
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: prawn
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 2.0.1
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.0.1
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.0.1
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.0.1
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: etc
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.2.0
|
80
|
+
type: :runtime
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.2.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: bundler
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.7'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '1.7'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: rake
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '10.0'
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - "~>"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '10.0'
|
115
|
+
description: Export iMessage conversations into TXT or PDF files
|
116
|
+
email:
|
117
|
+
- theodore.r.visser@gmail.com
|
118
|
+
executables:
|
119
|
+
- im_exporter
|
120
|
+
extensions: []
|
121
|
+
extra_rdoc_files: []
|
122
|
+
files:
|
123
|
+
- ".gitignore"
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/im_exporter
|
129
|
+
- im_porter.gemspec
|
130
|
+
- lib/im_exporter.rb
|
131
|
+
- lib/im_exporter/attachment.rb
|
132
|
+
- lib/im_exporter/contact.rb
|
133
|
+
- lib/im_exporter/message.rb
|
134
|
+
- lib/im_exporter/version.rb
|
135
|
+
homepage: https://github.com/noqcks/im_exporter
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.4.6
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: iMessage Exporter
|
159
|
+
test_files: []
|