Created
April 14, 2016 18:14
-
-
Save wosc/68ebd32911a7fb2a402878c398be9225 to your computer and use it in GitHub Desktop.
Convert delicious JSON export https://gist.github.com/wosc/0ea43e23d7efd4f4784540c174f0e80d to Netscape 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
#!/usr/bin/env python | |
import json | |
import sys | |
# See https://msdn.microsoft.com/en-us/library/aa753582%28VS.85%29.aspx | |
# and https://github.com/shaarli/Shaarli/blob/v0.6.5/index.php#L1899 | |
HEADER = u'<!DOCTYPE NETSCAPE-Bookmark-file-1><DL>' | |
FOOTER = u'</DL>' | |
ITEM = u'<DT><A HREF="{url}" ADD_DATE="{time_created}" TAGS="{tags}">{title}</A>' | |
bookmarks = json.load(sys.stdin) | |
print HEADER | |
for entry in bookmarks: | |
entry['tags'] = u' '.join(entry['tags']) | |
print ITEM.format(**entry).encode('utf-8') | |
print FOOTER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment