-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbookmarks.sql
96 lines (83 loc) · 2.67 KB
/
bookmarks.sql
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
-- Export your Firefox bookmarks into a reasonable format to import into Roam/Obsidian/Logseq
-- Usage:
-- copy your places.sqlite file from your Firefox profile into a new location, and open it with a SQL tool eg https://tableplus.com/
-- open places.sqlite and run the below query, export that to CSV and you have freed yourself form the dead fox
-- use https://github.com/Arrowyz01/csv2logseq_block to conver the CSV into MD, and wrangle the result into something usable
-- NB: modify the 'parent_folder' line to suit
with
bookmarks as (
select parents.title as parent_folder,
b.*,
datetime(datetime(b.dateadded/1000000,'unixepoch'), '+60 minute') as last_visit_date,
datetime(datetime(b.lastmodified/1000000,'unixepoch'), '+60 minute') as last_modified_date
from moz_bookmarks b
join moz_bookmarks parents on parents.id = b.parent
),
places as (
select
moz_places.url,
moz_places.title,
moz_places.frecency,
moz_places.visit_count,
moz_places.id as place_id,
datetime(datetime(moz_places.last_visit_date/1000000,'unixepoch'), '+60 minute') as last_visit_date,
moz_places.visit_count,
moz_places.hidden,
moz_places.typed,
moz_places.frecency,
moz_places.description,
replace(
replace(
replace(
replace(moz_places.url,"http://",""),"https://",""),"s:",""),"www.","")
as url_clean
from moz_places),
stage as (
select
places.place_id,
-- change which link type you want by varying these two comments
-- '#' || replace(bookmarks.parent_folder, ' ', '') as parent_folder,
'[[' || replace(bookmarks.parent_folder, ' ', '') || ']]' as parent_folder,
-- replace(bookmarks.parent_folder, ' ', '') as parent_folder,
bookmarks.title as titles,
places.title,
places.url,
places.url_clean,
places.frecency,
places.visit_count,
bookmarks.last_visit_date,
bookmarks.last_modified_date
from bookmarks
inner join places on bookmarks.fk = places.place_id
order by visit_count desc
),
names_group as (
select
place_id,
tags,
last_visit_date
from
(select
place_id ,
group_concat(parent_folder) as tags,
max(last_visit_date) as last_visit_date
from stage
group by url
) t
),
final as (
select distinct
names_group.tags,
names_group.place_id,
names_group.last_visit_date,
title,
url,
url_clean,
frecency,
visit_count
from names_group
left join stage on stage.place_id = names_group.place_id
order by frecency desc
)
select * from final
-- where lower(tags) like '%saas%'