-
Notifications
You must be signed in to change notification settings - Fork 0
/
sfbookmarks.py
executable file
·43 lines (37 loc) · 1.32 KB
/
sfbookmarks.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
#!/usr/bin/env python
import os
import argparse
import sys
import plistlib
def bookmarklist(path):
if path['WebBookmarkType'] == 'WebBookmarkTypeList':
if "Children" in path:
for n in path['Children']:
if n['WebBookmarkType'] == 'WebBookmarkTypeLeaf':
url = n["URLString"]
title = n["URIDictionary"]["title"]
if title == None:
title = ""
print(title)
print(url)
elif n['WebBookmarkType'] == 'WebBookmarkTypeList':
if "Children" in n:
for child in n['Children']:
bookmarklist(child)
elif path['WebBookmarkType'] == 'WebBookmarkTypeLeaf':
url = path["URLString"]
title = path["URIDictionary"]["title"]
if title == None:
title = ""
print(title)
print(url)
def main():
parser = argparse.ArgumentParser(description="sfbookmarks")
parser.add_argument("--path", help="Path of the PLIST file to be scanned")
args = vars(parser.parse_args())
plistPath = os.path.abspath(os.path.expanduser(args['path']))
with open(plistPath, 'rb') as data_file:
pl = plistlib.load(data_file)
bookmarklist(pl)
if __name__ == "__main__":
main()