Skip to content

Instantly share code, notes, and snippets.

@wosc
Created April 14, 2016 18:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wosc/68ebd32911a7fb2a402878c398be9225 to your computer and use it in GitHub Desktop.
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
#!/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