-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlistParser.sh
140 lines (115 loc) · 2.94 KB
/
PlistParser.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
echo
echo 'Plist Parser'
echo 'Generating Database...'
mkdir Plists;
find "$@" -name '*.plist' 2>/dev/null | cpio -pdm Plists;
find ./Plists -type f -name "*.plist" -exec plutil -convert xml1 "{}" \;
grep -rs "real>[2-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" -B 1 Plists > realcc.txt;
gsed -i '
s/,/;/g
/<\/key>/{ N; s/<\/key>.*<real>/,/}
s/plist-.*<key>/plist,/g
s/<\/real>//g
/<\/string/{ N; s/<\/string>.*<real>/,/}
s/plist-.*<string>/plist,/g
s/<\/dict>/dict,/g
/--/d
/addaily.plist/d
s/plist:.*<real>/plist,array,/g
/<integer>/d
/<real>/d
/<array>/d
/<\/array>/d
/dict,/d
/<false\/>/d
/PixelFormatType/d
' realcc.txt ;
grep -rs "integer>1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]<" -B 1 Plists > integer.txt ;
gsed -i '
s/,/;/g
/<\/key>/{ N; s/<\/key>.*<integer>/,/}
s/plist-.*<key>/plist,/g
/<\/string/{ N; s/<\/string>.*<integer>/,/}
/--/d
s/<\/integer>//g
s/plist-.*<string>/plist,/g
/integer>100/d
s/plist:.*<integer>/plist,array,/g
/<array>/d
/iTunesMetadata.plist/d
/RadioPlayBackHistoryStore/d
/<\/dict>/d
s/plist-.*<integer>/plist,array,/g
' integer.txt ;
grep -rs "real>[1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" -B 1 Plists > realeu.txt;
gsed -i '
s/,/;/g
/<\/key>/{ N; s/<\/key>.*<real>/,/}
s/plist-.*<key>/plist,/g
s/<\/real>//g
/<\/string/{ N; s/<\/string>.*<real>/,/}
s/plist-.*<string>/plist,/g
s/<\/dict>/dict,/g
/--/d
/addaily.plist/d
s/plist:.*<real>/plist,array,/g
/<integer>/d
/<real>/d
/<array>/d
/<\/array>/d
/dict,/d
/<false\/>/d
/PixelFormatType/d
' realeu.txt ;
grep -rs "<date>" -B 1 Plists > date.txt;
gsed -i '
s/,/;/g
/<\/key>/{ N; s/<\/key>.*<date>/,/}
/<\/string/{ N; s/<\/string>.*<date>/,/}
s/plist-.*<key>/plist,/g
s/Z<\/date>//g
/--/d
s/plist:.*<date>/plist,array,/g
/<array>/d
s/plist-.*<string>/plist,/g
' date.txt ;
{ echo "directory,activity,timestamp"; cat date.txt;} > dates.txt;
{ echo "directory,activity,timestamp"; cat integer.txt;} > integers.txt;
{ echo "directory,activity,timestamp"; cat realcc.txt;} > realc.txt;
{ echo "directory,activity,timestamp"; cat realeu.txt;} > realu.txt;
rm -r date.txt
rm -r integer.txt
rm -r realcc.txt
rm -r realeu.txt
sqlite3 <<'END_SQL'
.mode csv
.import dates.txt DATE
.import integers.txt INTEGER
.import realc.txt REALC
.import realu.txt REALU
UPDATE REALC
SET timestamp = datetime(timestamp + 978307200, 'unixepoch');
UPDATE REALU
SET timestamp = datetime(timestamp, 'unixepoch');
UPDATE INTEGER
SET timestamp = datetime(timestamp, 'unixepoch');
UPDATE DATE
SET timestamp = replace(timestamp, 'T', ' ');
CREATE TABLE Timestamps(directory Varchar, activity Varchar, timestamp datetime);
INSERT INTO Timestamps SELECT * FROM DATE;
INSERT INTO Timestamps SELECT * FROM INTEGER;
INSERT INTO Timestamps SELECT * FROM REALC;
INSERT INTO Timestamps SELECT * FROM REALU;
.save Timestamps.db
DROP TABLE DATE;
DROP TABLE INTEGER;
DROP TABLE REALC;
DROP TABLE REALU;
.save Timestamps.db
END_SQL
rm -r dates.txt
rm -r integers.txt
rm -r realc.txt
rm -r realu.txt
echo 'Done!'