Created
November 18, 2017 13:32
-
-
Save mrbidon/1629fd1b5781b041b684c3a493f8b645 to your computer and use it in GitHub Desktop.
Convert a Firefox jsonlz4 bookmark file to a Mozilla HTML bookmark format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # this little script convert a Firefox jsonlz4 bookmark file to a Mozilla HTML bookmark format | |
| import json | |
| import sys | |
| def parse(dic, title): | |
| result = "" | |
| result += '<DT><H3 FOLDED ADD_DATE="">{title}</H3>'.format(title=title) | |
| result += '<DL>' | |
| for url in dic: | |
| if "uri" in url: | |
| result += '<A HREF="{uri}" ADD_DATE="{date}" PRIVATE="0" TAGS="svg,reference">{title}</A>'.format(uri=url['uri'], date=url['lastModified'], title=url['title']) | |
| elif 'children' in url : | |
| result += parse(url['children'], url['title']) | |
| result += '</DL>' | |
| return result | |
| with open(sys.argv[1]) as f : | |
| print("""<!DOCTYPE NETSCAPE-Bookmark-file-1> | |
| <!--This is an automatically generated file. | |
| It will be read and overwritten. | |
| Do Not Edit! --> | |
| <Title>Bookmarks</Title> | |
| <H1>Bookmarks</H1>""") | |
| parsed = json.loads(f.read()) | |
| if('children' in parsed): | |
| print(parse(parsed['children'], parsed['title'])) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't see these comment....
It's a one shot script I've done and find that might be helpful (And in fact, it is :))
As @BasicAcid said, you have to use dejsonlz4 first to make it works