2023-04-04 09:15:28 +03:00
|
|
|
import subprocess
|
|
|
|
import json
|
|
|
|
import hashlib
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
2023-04-04 22:55:16 +03:00
|
|
|
COMMAND = './external/rentry'
|
|
|
|
NAME = 'rentry'
|
|
|
|
|
|
|
|
def get_service_tag():
|
|
|
|
return NAME
|
|
|
|
|
2023-04-04 09:15:28 +03:00
|
|
|
def upload(data):
|
|
|
|
md5sum = hashlib.md5(json.dumps(data).encode('utf-8')).hexdigest()
|
2023-04-04 22:55:16 +03:00
|
|
|
command = [ COMMAND, 'new', json.dumps(data)]
|
2023-04-04 09:15:28 +03:00
|
|
|
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}
|
|
|
|
|