Skip to content

Instantly share code, notes, and snippets.

@yesokay
Created August 4, 2017 23:02
Show Gist options
  • Save yesokay/733f9060b42af2910c96c747c7cf947e to your computer and use it in GitHub Desktop.
Save yesokay/733f9060b42af2910c96c747c7cf947e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
'''
Since stash.ai became a paid-only service while still offering a super buggy product, I decided to switch to Raindrop.io
This shamelessly sloppy script might help you do the same.
Usage: ./stash-to-raindrop.py stash-export.json generated-file
'''
import sys
import json
def convert(f, output):
with open(f) as data_file:
data = json.load(data_file)
outfile = output + '.html'
export = open(outfile, 'w')
export.write(
'<!DOCTYPE NETSCAPE-Bookmark-file-1>\n' +
'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">\n' +
'<TITLE>Bookmarks</TITLE>\n' +
'<H1>Bookmarks</H1>\n'
'<DL>\n'
)
for bookmark in data:
export.write('<dt>')
export.write(
'<a href="' + bookmark['url'] + '" ' +
'add_date="' + str(int(bookmark['timestamp'])) + '">' +
str(bookmark['title']).lstrip().rstrip() + # Just to be safe
'</a>'
)
export.write('</dt>\n')
export.write('</DL>')
export.close()
print('\n** Exported {} bookmarks to {} **'.format(len(data), outfile))
print('** Visit http://raindrop.io/app/#/settings/import/start to upload. **')
if __name__ == '__main__':
convert(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment