Skip to content

Instantly share code, notes, and snippets.

@void4
Created August 4, 2017 13:08
Show Gist options
  • Save void4/925545383338fd9a0a3779fd6b9c725c to your computer and use it in GitHub Desktop.
Save void4/925545383338fd9a0a3779fd6b9c725c to your computer and use it in GitHub Desktop.
import json
import requests
username = ""
password = ""
customui = """
[
{
"button_panels": [
{
"button_panel_label": "movement controls",
"buttons": [
{
"label": "left",
"command": "R"
}
]
}
]
}
]
"""
response = requests.request("POST", "https://letsrobot.tv/api/v1/authenticate", data=json.dumps({'username': username, 'password': password}), headers={'content-type': 'application/json'})
print(response)
cookies={'connect.sid' : response.cookies['connect.sid']}
recv_robot = requests.request("GET", "https://letsrobot.tv/api/v1/accounts/", cookies=cookies)
print(recv_robot)
robot_id = 33583635
j = json.loads(recv_robot.content)
index = [i for i,r in enumerate(j["robots"]) if r["robot_id"]==str(robot_id)][0]
print(j["robots"][index])
j["robots"][index]["panels"] = str(customui)#json.loads(customui)
print(json.dumps({"robots":j["robots"]}, indent=4, sort_keys=True))
send_robot = requests.request("POST", "https://letsrobot.tv/api/v1/accounts/robots", data=json.dumps({"robots":j["robots"]}), cookies=cookies, headers={'content-type': 'application/json'})
print(send_robot)
print(send_robot.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment