-
Notifications
You must be signed in to change notification settings - Fork 0
/
ryzom_base.py
executable file
·68 lines (54 loc) · 1.32 KB
/
ryzom_base.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
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 19 17:01:20 2020
@author: planetmaker
"""
from enum import Enum
ryzom_base_url = "https://api.ryzom.com/"
ryzom_api_endpoints = {
'character': {'url': "character.php", 'params': ['apikey']},
'guild': {'url': "guild.php", 'params': ['apikey']},
}
def compose_ryzom_api_url(endpoint, params=[]):
try:
url = ryzom_api_endpoints[endpoint]['url']
except:
return None
if params is list():
return url
for num,param in enumerate(params):
c = '?' if num == 1 else '&'
if param[0] in ryzom_api_endpoints[endpoint]['params']:
try:
url += c + param[0] + "=" + param[1]
except:
pass
return url
class API_error(Enum):
INVALID_API_KEY = 404
KEY_EXPIRED = 403
NOT_INITIALIZED = 503 # for both character and guild
class Colour(Enum):
undefined = -1
red = 0
beige = 1
orange = 2
green = 3
turquoise = 4
blue = 5
purple = 6
white = 7
black = 8
class Ecosystem(Enum):
undefined = 0
desert = 1
wood = 2
lake = 3
jungle = 4
roots = 6
class Race(Enum):
Tryker = 0
Matis = 1
Fyros = 2
Zorai = 3