17 lines
550 B
Python
17 lines
550 B
Python
|
import subprocess
|
||
|
import json
|
||
|
import hashlib
|
||
|
import re
|
||
|
|
||
|
|
||
|
def upload(data):
|
||
|
md5sum = hashlib.md5(json.dumps(data).encode('utf-8')).hexdigest()
|
||
|
command = ['./external/rentry', 'new', json.dumps(data)]
|
||
|
output = subprocess.check_output(command, universal_newlines=True)
|
||
|
#print(output)
|
||
|
lines = output.strip().split('\n')
|
||
|
url = re.search("(?P<url>https?://[^\s]+)", lines[0]).group("url")
|
||
|
edit_code = lines[1].split(':')[-1].strip()
|
||
|
return {'name': 'rentry_' + edit_code, 'service': 'Rentry', 'key': url, 'md5sum': md5sum}
|
||
|
|