Steven Smith revised this gist . Go to revision
1 file changed, 2 insertions, 2 deletions
toornament_customfield.py
| @@ -12,8 +12,8 @@ customfield = { | |||
| 12 | 12 | } | |
| 13 | 13 | ||
| 14 | 14 | s = requests.Session() | |
| 15 | - | token = s.get("https://account.toornament.com/login/").text.split('<input type="hidden" id="_token" name="_token" value="',1)[1].split('"',1)[0] | |
| 15 | + | token = s.get("https://account.toornament.com/login/").text.split('name="_token" value="',1)[1].split('"',1)[0] | |
| 16 | 16 | s.post("https://account.toornament.com/login_check", data={"_username": email_addr, "_password": password, "_token": token}) | |
| 17 | - | token2 = s.get("https://organizer.toornament.com/tournaments/{}/participants/settings/custom-field/create?target-type=player&type=text".format(toornament_id)).text.split('<input type="hidden" id="custom_field_create__token" name="custom_field_create[_token]" value="',1)[1].split('"',1)[0] | |
| 17 | + | token2 = s.get("https://organizer.toornament.com/tournaments/{}/participants/settings/custom-field/create?target-type=player&type=text".format(toornament_id)).text.split('name="custom_field_create[_token]" value="',1)[1].split('"',1)[0] | |
| 18 | 18 | x = "custom_field_create[{}]"# | |
| 19 | 19 | s.post("https://organizer.toornament.com/tournaments/{}/participants/settings/custom-field/create".format(toornament_id), params={"target-type": "player", "type": "text"}, data=dict(x.format("_token")=token2, **customfield) | |
Steven Smith revised this gist . Go to revision
1 file changed, 19 insertions
toornament_customfield.py(file created)
| @@ -0,0 +1,19 @@ | |||
| 1 | + | #!/usr/bin/env python3 | |
| 2 | + | import requests | |
| 3 | + | toornament_id = input("Toornament ID: ")# "1262174713922625536" | |
| 4 | + | email_addr = input("Email address: ")# "stevensmith.ome@gmail.com" | |
| 5 | + | password = input("Password: ") | |
| 6 | + | customfield = { | |
| 7 | + | x.format("label"): "Discord UN", | |
| 8 | + | x.format("machineName"): "discord_un", | |
| 9 | + | x.format("position"): 2, | |
| 10 | + | x.format("required"): 1, | |
| 11 | + | x.format("public"): 1 | |
| 12 | + | } | |
| 13 | + | ||
| 14 | + | s = requests.Session() | |
| 15 | + | token = s.get("https://account.toornament.com/login/").text.split('<input type="hidden" id="_token" name="_token" value="',1)[1].split('"',1)[0] | |
| 16 | + | s.post("https://account.toornament.com/login_check", data={"_username": email_addr, "_password": password, "_token": token}) | |
| 17 | + | token2 = s.get("https://organizer.toornament.com/tournaments/{}/participants/settings/custom-field/create?target-type=player&type=text".format(toornament_id)).text.split('<input type="hidden" id="custom_field_create__token" name="custom_field_create[_token]" value="',1)[1].split('"',1)[0] | |
| 18 | + | x = "custom_field_create[{}]"# | |
| 19 | + | s.post("https://organizer.toornament.com/tournaments/{}/participants/settings/custom-field/create".format(toornament_id), params={"target-type": "player", "type": "text"}, data=dict(x.format("_token")=token2, **customfield) | |