-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfx_bmark_extract.py
More file actions
executable file
·37 lines (30 loc) · 940 Bytes
/
fx_bmark_extract.py
File metadata and controls
executable file
·37 lines (30 loc) · 940 Bytes
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
#!/usr/bin/env python
"""
Import a Firefox bookmarks file into a single json list
"""
import json
import pprint
def walk(struct, depth=0):
children = struct.get('children')
if children:
for child in children:
if child.get('type') == 'text/x-moz-place':
title = child.get('title')
uri = child.get('uri')
tags = child.get('tags')
if tags:
tag_l = [tag for tag in tags.split(',')]
else:
tag_l = []
out_dict = {'title': title,
'uri': uri,
'tags': tag_l
}
if out_dict not in my_marks:
my_marks.append(out_dict)
walk(child)
with open("bmarks") as f:
my_marks = []
j = json.load(f)
walk(j)
print(json.dumps(my_marks, indent=2))