Commit 62d137cb authored by alexandre's avatar alexandre

Snapshot code wip

parent 884d101e
import os
import requests
api_key = "ZEojF6PGrOomABIXDf4igo9XfCdWaZL5"
pad_id = "metahoguet"
base_url = "http://pads.osp.kitchen"
api_url = "{}/api/1/".format(base_url)
params = {"padID": pad_id, "apikey": api_key}
outdir = "/tmp/foobar"
letter = "A"
r = requests.get('{}getRevisionsCount'.format(api_url), params=params)
rev = r.json().get("data").get("revisions")
rev_dir = os.path.join(outdir, "{}_{}".format(rev, letter))
try:
os.makedirs(os.path.join(rev_dir))
except:
pass
r = requests.get('{}getText'.format(api_url), params=dict(revision=rev, **params))
text = r.json().get("data").get("text")
fn = os.path.join(rev_dir, "source.mp")
f = open(fn, "w")
f.write(text)
# metamonday.mp && mpost -interaction=batchmode metamonday.mp
# Downloads the latest revision and get the line number of the given fig
curl -s http://pads.osp.kitchen/p/metamonday/export/txt | grep -n "beginfig($1)"
curl -s http://pads.osp.kitchen/api/1/getRevisionsCount\?padID\=metamonday\&apikey\=ZEojF6PGrOomABIXDf4igo9XfCdWaZL5 | python -c 'import sys, json; print(json.load(sys.stdin)["data"]["revisions"])'
curl -s http://pads.osp.kitchen/api/1/getText\?padID\=metamonday\&revision\=17186\&apikey\=ZEojF6PGrOomABIXDf4igo9XfCdWaZL5 | python -c 'import sys, json; print(json.load(sys.stdin)["data"]["text"])'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment