-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffbookmarks.py
executable file
·53 lines (46 loc) · 1.92 KB
/
ffbookmarks.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
import os
import argparse
import sys
import json
from datetime import datetime, timedelta, timezone
from pprint import pprint
# Decompress Mozilla Firefox bookmarks .jsonlz4 backup files to .json:
# https://github.com/andikleen/lz4json
def bookmarklist(path):
if path['type'] == 'text/x-moz-place-container':
if 'children' in path:
for n in path['children']:
if n['type'] == 'text/x-moz-place':
if n['title'] == None:
title = ""
else:
title = n['title']
print(title)
print(datetime.utcfromtimestamp(float(n['dateAdded'])/1000000.).strftime('%Y-%m-%d %H:%M:%S.%f'))
print(datetime.utcfromtimestamp(float(n['lastModified'])/1000000.).strftime('%Y-%m-%d %H:%M:%S.%f'))
print(n['uri'])
elif n['type'] == 'text/x-moz-place-container':
if 'children' in n:
for child in n['children']:
bookmarklist(child)
elif path['type'] == 'text/x-moz-place':
if path['title'] == None:
title = ""
else:
title = path['title']
print(title)
print(datetime.utcfromtimestamp(float(path['dateAdded'])/1000000.).strftime('%Y-%m-%d %H:%M:%S.%f'))
print(datetime.utcfromtimestamp(float(path['lastModified'])/1000000.).strftime('%Y-%m-%d %H:%M:%S.%f'))
print(path['uri'])
def main():
parser = argparse.ArgumentParser(description="chbookmarks")
parser.add_argument("--path", help="Path of the JSON file to be scanned")
args = vars(parser.parse_args())
jsonPath = os.path.abspath(os.path.expanduser(args['path']))
with open(jsonPath) as data_file:
for jsonObject in data_file:
root = json.loads(jsonObject)
bookmarklist(root)
if __name__ == "__main__":
main()