Log in to HackMD and download your history file by clicking on the save icon.
Then run python dhmd.py yourHistory.json
.
import os, sys, wget, json | |
if len(sys.argv) > 1: | |
fn = sys.argv[1] | |
else: | |
print('Download your HackMD history file run $ python dhmd.py yourHistory.json') | |
sys.exit() | |
with open(fn, 'r') as json_data: | |
history = json.load(json_data) | |
directory = os.path.join(os.path.dirname(fn), 'notes') | |
if not os.path.exists(directory): | |
os.makedirs(directory) | |
for note in history: | |
url = '{}/{}/{}'.format('https://hackmd.io', note['id'], 'download') | |
print('\n\n{}\t{}\n'.format(note['text'], url)) | |
try: | |
wget.download(url, directory) | |
except ValueError: | |
print('Error while downloading: {}'.format(url)) | |
print('Done!') | |
sys.exit() |