-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompetition_url.py
65 lines (55 loc) · 1.14 KB
/
competition_url.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import json
import urllib.parse
import pyperclip
SERVER_HOST = 'localhost:8080'
SEED = None
LENGTH = None
PLAYERS = [
{
'name': 'Baratheon',
'address': '127.0.0.1:8080',
},
{
'name': 'Greyjoy',
'address': '127.0.0.1:8080',
},
{
'name': 'Martell',
'address': '127.0.0.1:8080',
},
{
'name': 'Stark',
'address': '127.0.0.1:8080',
},
{
'name': 'Tully',
'address': '127.0.0.1:8080',
},
{
'name': 'Tyrell',
'address': '127.0.0.1:8080',
},
{
'name': 'Lannister',
'address': '127.0.0.1:8080',
},
{
'name': 'Frey',
'address': '127.0.0.1:8080',
},
]
def make_competition_url():
data = {}
if SEED:
data['seed'] = SEED
if LENGTH:
data['length'] = LENGTH
data['players'] = urllib.parse.quote(json.dumps(PLAYERS))
qs = urllib.parse.urlencode(data)
return urllib.parse.urlunparse(('http', SERVER_HOST, '', '', qs, ''))
def main():
url = make_competition_url()
print(url)
pyperclip.copy(url)
if __name__ == '__main__':
main()