#!/usr/bin/env python3
import json
import urllib.request as urlreq
from urllib.parse import urlencode
import sys
SERVER="https://paste.openttdcoop.org"
DEFAULT_LANG="diff"
payload = {}
payload["data"] = sys.stdin.read()
lang = DEFAULT_LANG
if len(sys.argv) > 1:
lang = sys.argv[1]
payload["language"] = lang
form_data = urlencode(payload, doseq=True)
print(form_data)
req = urlreq.urlopen(SERVER + "/api/json/create", form_data.encode("utf-8"))
print(req.read())