a small tkinter gui to browse the .json type bookmark files firefox automatically generates each day. It's meant to be run from a terminal. If a tree item is doubleclicked it prints the uri.
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 | import sys
from argparse import ArgumentParser
from Tkinter import *
sys.path.append(r'/usr/lib/python2.7/idlelib')
from TreeWidget import FileTreeItem, TreeNode, ScrolledCanvas
class MyFileTreeItem(FileTreeItem):
def GetText(self):
return self.path.get("title")
def SetText(self, text):
pass
def GetSubList(self):
return [MyFileTreeItem(name) for name in self.path['children']]
def IsExpandable(self):
"""Return whether there are subitems."""
return self.path.has_key('children')
def IsEditable(self):
pass
def OnDoubleClick(self):
if not self.IsExpandable():
print self.path.get('uri','no uri available')
def main():
parser = ArgumentParser(description = 'browse a bookmarks_xxx.json file')
parser.add_argument('jbfile',
help='the json file containing the bookmarks')
args = parser.parse_args()
root = Tk()
sys.exitfunc = root.quit
root.configure(bd=0, bg="yellow")
root.title("bookmarks browser")
root.focus_set()
sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both")
fn =args.jbfile
D = eval(file(fn).read())
D['title'] = fn
item = MyFileTreeItem(D)
node = TreeNode(sc.canvas, None, item)
node.expand()
root.mainloop()
if __name__=='__main__':
main()
|
I removed firefox without checking that all my bookmarks were exported after using firefox' utily. Luckily there was another place where the bookmarks were stored, they were even in a format that could easily be read into a dictionary! Using some code that still exists in many python installs, but that has to be added to python's path to be used again, I managed to create a minimal gui. The script is only tested for debian.
To find the .json files the script uses as an argument, type "locate bookmarks | grep json".
Run the script like so: python bookmarks.py somefile.json.