evernote-analyzer 0.0.9
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.
- checksums.yaml +7 -0
- data/bin/evernote-analyzer +4 -0
- data/lib/evernote-analyzer.rb +2 -0
- data/lib/evernote-exporter.rb +112 -0
- metadata +61 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: fe44a150057b28d895aa7d5796fd7c4902fbad15302a2393ca3f1366e074ae06
|
|
4
|
+
data.tar.gz: a9e59dd42b94de0831a51c02bce0efe1afdbfe015b65423af5f522a55c626f08
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: af15aa61075cda8a8dd6062a250ee271a3ddca652b443458e2f4dbb4d7c3393e175865a1d29f1ad4d116cf2f4f301f5a8e572edf6f4439e195439b23938872cd
|
|
7
|
+
data.tar.gz: 6a835c57cb940c3740c51aaf205c7c913b1adcad865d5efe9148a8f6f64b63e1add28de78a1d571fac4faf56ddfaac661d92637e4e34db043793c8a1acd71733
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# encoding=utf-8
|
|
2
|
+
require 'csv'
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'sqlite3'
|
|
5
|
+
|
|
6
|
+
class Numeric
|
|
7
|
+
def number_to_human_size(shortly = false)
|
|
8
|
+
result = _to_human_size(self.to_i)
|
|
9
|
+
result = result.first(2) if shortly
|
|
10
|
+
result.join.strip
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def _to_human_size(num, result = [], index = 0)
|
|
14
|
+
human_units = ['B ', 'K ', 'M ', 'G ', 'T ', 'P ']
|
|
15
|
+
|
|
16
|
+
if num >= 1024
|
|
17
|
+
div, mod = num.divmod(1024)
|
|
18
|
+
result.unshift([mod, human_units[index]])
|
|
19
|
+
_to_human_size(div, result, index + 1)
|
|
20
|
+
else
|
|
21
|
+
result.unshift([num, human_units[index]])
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class EvernoteExporter
|
|
27
|
+
class << self
|
|
28
|
+
def do
|
|
29
|
+
whoami = `whoami`.strip
|
|
30
|
+
local_account_folder = "/Users/#{whoami}/Library/Application Support/com.yinxiang.Mac/accounts/app.yinxiang.com"
|
|
31
|
+
|
|
32
|
+
Dir.glob([local_account_folder, '*'].join('/')) do |local_account_path|
|
|
33
|
+
account_note_exporter(local_account_path)
|
|
34
|
+
puts "\n"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def account_note_exporter(local_account_path)
|
|
39
|
+
account_id = File.basename(local_account_path)
|
|
40
|
+
sqlite3_db_path = "#{local_account_path}/localNoteStore/LocalNoteStore.sqlite"
|
|
41
|
+
sqlite3_db_connection = SQLite3::Database.new(sqlite3_db_path)
|
|
42
|
+
|
|
43
|
+
csv_export_filename = "evernote-#{account_id}-#{Time.now.strftime('%y%m%d%H%M')}.csv"
|
|
44
|
+
CSV.open(csv_export_filename, "wb") do |csv_row|
|
|
45
|
+
csv_row << ['笔记本组', '笔记本', '标题', '更新时间', '笔记大小', '存储大小', '存储大小(格式化)', '存储路径']
|
|
46
|
+
|
|
47
|
+
note_index = 1
|
|
48
|
+
note_count = sqlite3_db_connection.execute(sql_note_count).to_a.flatten[0]
|
|
49
|
+
sqlite3_db_connection.prepare(sql_note_list).execute.each_hash do |record|
|
|
50
|
+
filesize_hash = _local_note_filesize(record['uuid'])
|
|
51
|
+
csv_row << [record['zstack'], record['zname'], record['title'], record['updated_at'], record['note_size'], filesize_hash[:local_note_size], filesize_hash[:local_note_size_human], filesize_hash[:local_note_path]]
|
|
52
|
+
set_progress(note_index, note_count, account_id)
|
|
53
|
+
note_index += 1
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
puts "Export evernote(#{account_id}) notes to #{csv_export_filename}, Done!"
|
|
58
|
+
puts "Execute `open #{csv_export_filename}`\n"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
protected
|
|
62
|
+
|
|
63
|
+
def set_progress(offset, total, account_id, char = '*')
|
|
64
|
+
inx = (1.0*offset/total*100).round(0)
|
|
65
|
+
print "Export evernote(#{account_id}) notes: ", (char * (inx / 2.5).floor).ljust(45, " "), " #{inx}%(#{offset}/#{total})\r"
|
|
66
|
+
sleep 0.005
|
|
67
|
+
$stdout.flush
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def _local_note_path(uuid)
|
|
71
|
+
"#{@local_account_path}/content/#{uuid}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def _local_note_filesize(uuid)
|
|
75
|
+
filesize_hash = {
|
|
76
|
+
'local_note_path': _local_note_path(uuid),
|
|
77
|
+
'local_note_size': 0
|
|
78
|
+
}
|
|
79
|
+
Dir.glob([filesize_hash[:local_note_path], '*'].join('/')) do |path|
|
|
80
|
+
filesize_hash[File.basename(path)] = File.size(path)
|
|
81
|
+
filesize_hash[:local_note_size] += filesize_hash[File.basename(path)] || 0
|
|
82
|
+
end
|
|
83
|
+
filesize_hash[:local_note_size_human] = filesize_hash[:local_note_size].number_to_human_size
|
|
84
|
+
return filesize_hash
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def sql_note_count
|
|
88
|
+
<<-EOF
|
|
89
|
+
SELECT
|
|
90
|
+
count() as cnt
|
|
91
|
+
FROM ZENNOTE;
|
|
92
|
+
EOF
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def sql_note_list
|
|
96
|
+
<<-EOF
|
|
97
|
+
SELECT
|
|
98
|
+
note.ZTITLE as title,
|
|
99
|
+
notebook.ZNAME as zname,
|
|
100
|
+
notebook.ZSTACK as zstack,
|
|
101
|
+
date(datetime(note.ZDATEUPDATED, 'unixepoch', 'localtime'), '+31 years') as updated_at,
|
|
102
|
+
note.ZDATALENGTH as note_size,
|
|
103
|
+
note.ZLOCALUUID as uuid
|
|
104
|
+
FROM ZENNOTE as note
|
|
105
|
+
LEFT JOIN ZENNOTEBOOK as notebook on note.ZNOTEBOOK = notebook.Z_PK
|
|
106
|
+
ORDER BY note.ZDATEUPDATED DESC;
|
|
107
|
+
EOF
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
|
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: evernote-analyzer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.9
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jaden Li
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-08-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: sqlite3
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: Evernote exporter/analyzer
|
|
28
|
+
email:
|
|
29
|
+
- jaden.li@jaden.tech
|
|
30
|
+
executables:
|
|
31
|
+
- evernote-analyzer
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- bin/evernote-analyzer
|
|
36
|
+
- lib/evernote-analyzer.rb
|
|
37
|
+
- lib/evernote-exporter.rb
|
|
38
|
+
homepage: https://github.com/imjaden/evernote-analyzer.git
|
|
39
|
+
licenses:
|
|
40
|
+
- MIT
|
|
41
|
+
metadata: {}
|
|
42
|
+
post_install_message:
|
|
43
|
+
rdoc_options: []
|
|
44
|
+
require_paths:
|
|
45
|
+
- lib
|
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: 2.0.0
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: 1.3.5
|
|
56
|
+
requirements: []
|
|
57
|
+
rubygems_version: 3.1.0.pre1
|
|
58
|
+
signing_key:
|
|
59
|
+
specification_version: 4
|
|
60
|
+
summary: Evernote exporter/analyzer
|
|
61
|
+
test_files: []
|