Last active
March 12, 2018 09:24
-
-
Save blha303/6df5ce77cfdf4d5e47fc5f0950f3e7e4 to your computer and use it in GitHub Desktop.
Creating a custom field in Toornament (Python3+requests)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
toornament_id = input("Toornament ID: ")# "1262174713922625536" | |
email_addr = input("Email address: ")# "[email protected]" | |
password = input("Password: ") | |
customfield = { | |
x.format("label"): "Discord UN", | |
x.format("machineName"): "discord_un", | |
x.format("position"): 2, | |
x.format("required"): 1, | |
x.format("public"): 1 | |
} | |
s = requests.Session() | |
token = s.get("https://account.toornament.com/login/").text.split('name="_token" value="',1)[1].split('"',1)[0] | |
s.post("https://account.toornament.com/login_check", data={"_username": email_addr, "_password": password, "_token": token}) | |
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] | |
x = "custom_field_create[{}]"# | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment