-
Notifications
You must be signed in to change notification settings - Fork 0
/
StandaloneMacSafari.py
31 lines (29 loc) · 1.27 KB
/
StandaloneMacSafari.py
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
import os, GenerateStandalone
databaseInputFile = os.path.join(os.path.expanduser("~"), "Library", "Safari", "History.db")
sqlHistoryItems = "\
SELECT \
history_items.id, \
history_items.url, \
history_visits.title, \
MAX(CAST(1000 * history_visits.visit_time AS INT) + 978307200000) AS lastVisitTime, \
history_items.visit_count AS visitCount, \
0 AS typedCount \
FROM history_visits \
INNER JOIN history_items ON history_items.id = history_visits.history_item \
GROUP BY history_items.id \
ORDER BY lastVisitTime DESC;" # replace "typedCount" with real data if/when it becomes available in Safari
sqlVisitItems = "\
SELECT \
history_visits.history_item AS id, \
history_visits.id AS visitId, \
CAST(1000 * history_visits.visit_time AS INT) + 978307200000 AS visitTime, \
IFNULL(history_visits.redirect_source, 0) AS referringVisitId, \
CASE history_visits.redirect_source \
WHEN NULL THEN \"typed\" \
ELSE \"link\" \
END AS transition, \
history_visits.origin AS visitOrigin \
FROM history_visits \
ORDER BY history_visits.visit_time DESC;" # replace "transition" with real data if/when it becomes available in Safari
copyDatabaseInputFile = False
GenerateStandalone.generateStandalone(databaseInputFile, sqlHistoryItems, sqlVisitItems, copyDatabaseInputFile)