X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=sidebyside;f=Storage%2Fbkmk_stjson.py;h=1194aed0743167fc796724fbab3784d001fb7f29;hb=3de6c8f6da84fdc757f3b4a3355ed502c4a75318;hp=cd6139faa36c66afdaf65c57deb479e13e46b99f;hpb=70c4014812c5406cd7e675dbf6af95eaaeb7e04d;p=bookmarks_db.git diff --git a/Storage/bkmk_stjson.py b/Storage/bkmk_stjson.py index cd6139f..1194aed 100644 --- a/Storage/bkmk_stjson.py +++ b/Storage/bkmk_stjson.py @@ -39,6 +39,8 @@ class storage_json(Walker): dict["lastModified"] = f.last_modified parent_idx = getattr(f, 'parent_idx') if parent_idx: dict["parent"] = parent_idx + root = getattr(f, 'root') + if root: dict["root"] = root dict["title"] = f.name.decode('utf-8') dict["type"] = "text/x-moz-place-container" self.folder_stack[-1].append(dict) @@ -63,7 +65,17 @@ class storage_json(Walker): dict["parent"] = b.parent_idx dict["title"] = b.name.decode('utf-8') dict["type"] = "text/x-moz-place" - dict["uri"] = b.href + dict["uri"] = uri = b.href + if uri.startswith('place:'): + if uri.startswith('place:sort=8'): + value = 'MostVisited' + elif uri.startswith('place:folder=BOOKMARKS_MENU'): + value = 'RecentlyBookmarked' + elif uri.startswith('place:sort=14'): + value = 'RecentTags' + dict["annos"] = make_annos(value, name='Places/SmartBookmark') + del dict["dateAdded"] + del dict["lastModified"] self.folder_stack[-1].append(dict) def ruler(self, r, level): @@ -118,6 +130,7 @@ class storage_json(Walker): folder.id = fdict["id"] folder.index = fdict.get("index") folder.parent_idx = fdict.get("parent") + folder.root = fdict.get("root") folder.name = encode(fdict["title"]) for record in fdict["children"]: @@ -179,11 +192,11 @@ def get_comment(annos): return None -def make_annos(comment): +def make_annos(value, name="bookmarkProperties/description"): return [{ "expires": 4, "flags": 0, "mimeType": None, - "name": "bookmarkProperties/description", + "name": name, "type": 3, - "value": comment.decode('utf-8')}] + "value": value.decode('utf-8')}]