#!/usr/bin/env python3

import xml.etree.ElementTree as ET

tree = ET.parse("you_still_need_this/sitebar-bookmarks-201301.xbel")

def parse_bookmarks(node, indent=1):
    for el in node:
        if el.tag == "title":
            print("{} {}".format("*"*indent, el.text))
        elif el.tag == "bookmark":
            url = el.attrib["href"]
            title = el.find("./title")
            desc = el.find("./desc")
            date = el.attrib["added"]
            print("{}- {}: [[{}][{}]]".format(" "*(indent + 1), date[:10], url, title.text))
            if desc is not None:
                print("{}  {}".format(" "*(indent + 1), desc.text))
    for el in node:
        if el.tag == "folder":
            parse_bookmarks(el, indent + 1)

parse_bookmarks(tree.getroot())
