rustat-python-api 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rustat-python-api-0.1.1/rustat_python_api.egg-info → rustat-python-api-0.1.2}/PKG-INFO +3 -1
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/README.md +2 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api/parser.py +41 -6
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api/urls.py +2 -1
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2/rustat_python_api.egg-info}/PKG-INFO +3 -1
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/setup.py +1 -1
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/LICENSE +0 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/pyproject.toml +0 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api/__init__.py +0 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api.egg-info/SOURCES.txt +0 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api.egg-info/dependency_links.txt +0 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api.egg-info/requires.txt +0 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api.egg-info/top_level.txt +0 -0
- {rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rustat-python-api
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A Python wrapper for RuStat API
|
|
5
5
|
Home-page: https://github.com/dailydaniel/rustat-python-api
|
|
6
6
|
Author: Daniel Zholkovsky
|
|
@@ -41,4 +41,6 @@ match_id = keys[-1]
|
|
|
41
41
|
events = parser.get_events(match_id)
|
|
42
42
|
|
|
43
43
|
stats = parser.get_match_stats(match_id)
|
|
44
|
+
|
|
45
|
+
tracking = parser.get_tracking(match_id)
|
|
44
46
|
```
|
|
@@ -7,7 +7,7 @@ from .urls import URLs
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class RuStatParser:
|
|
10
|
-
def __init__(self, user: str, password: str):
|
|
10
|
+
def __init__(self, user: str, password: str, urls: dict = URLs):
|
|
11
11
|
self.numeric_columns = [
|
|
12
12
|
'id', 'number', 'player_id', 'team_id', 'half', 'second',
|
|
13
13
|
'pos_x', 'pos_y', 'pos_dest_x', 'pos_dest_y', 'len', 'possession_id', 'possession_team_id',
|
|
@@ -17,6 +17,7 @@ class RuStatParser:
|
|
|
17
17
|
|
|
18
18
|
self.user = user
|
|
19
19
|
self.password = password
|
|
20
|
+
self.urls = urls
|
|
20
21
|
|
|
21
22
|
self.cached_info = {}
|
|
22
23
|
|
|
@@ -28,7 +29,7 @@ class RuStatParser:
|
|
|
28
29
|
def get_rpl_info(self):
|
|
29
30
|
for season_id in tqdm(range(1, 36)):
|
|
30
31
|
data = self.resp2data(
|
|
31
|
-
|
|
32
|
+
self.urls["tournament_teams"].format(
|
|
32
33
|
user=self.user,
|
|
33
34
|
password=self.password,
|
|
34
35
|
season_id=season_id
|
|
@@ -38,7 +39,7 @@ class RuStatParser:
|
|
|
38
39
|
if data:
|
|
39
40
|
first_team_id = data["data"]["row"][0]["id"]
|
|
40
41
|
first_team_schedule = self.resp2data(
|
|
41
|
-
|
|
42
|
+
self.urls["schedule"].format(
|
|
42
43
|
user=self.user,
|
|
43
44
|
password=self.password,
|
|
44
45
|
team_id=first_team_id,
|
|
@@ -61,7 +62,7 @@ class RuStatParser:
|
|
|
61
62
|
|
|
62
63
|
def get_schedule(self, team_id: str, season_id: str) -> dict:
|
|
63
64
|
data = self.resp2data(
|
|
64
|
-
|
|
65
|
+
self.urls["schedule"].format(
|
|
65
66
|
user=self.user,
|
|
66
67
|
password=self.password,
|
|
67
68
|
team_id=team_id,
|
|
@@ -85,7 +86,7 @@ class RuStatParser:
|
|
|
85
86
|
|
|
86
87
|
def get_events(self, match_id: int) -> pd.DataFrame | None:
|
|
87
88
|
data = self.resp2data(
|
|
88
|
-
|
|
89
|
+
self.urls["events"].format(
|
|
89
90
|
user=self.user,
|
|
90
91
|
password=self.password,
|
|
91
92
|
match_id=match_id
|
|
@@ -102,9 +103,43 @@ class RuStatParser:
|
|
|
102
103
|
|
|
103
104
|
return df
|
|
104
105
|
|
|
106
|
+
def get_tracking(self, match_id: int) -> pd.DataFrame | None:
|
|
107
|
+
data = self.resp2data(
|
|
108
|
+
self.urls["tracking"].format(
|
|
109
|
+
user=self.user,
|
|
110
|
+
password=self.password,
|
|
111
|
+
match_id=match_id
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if not data:
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
data = data["data"]["team"]
|
|
119
|
+
df = pd.DataFrame(columns=["half", "second", "pos_x", "pos_y", "team_id", "player_id", "player_name", "side_1h"])
|
|
120
|
+
|
|
121
|
+
for team_data in tqdm(data):
|
|
122
|
+
team_id = team_data["id"]
|
|
123
|
+
side_1h = team_data["gate_position_half_1"]
|
|
124
|
+
|
|
125
|
+
for player_data in team_data["player"]:
|
|
126
|
+
player_id = player_data["id"]
|
|
127
|
+
player_name = player_data["name"]
|
|
128
|
+
|
|
129
|
+
cur_df = pd.json_normalize(player_data["row"])
|
|
130
|
+
cur_df = cur_df.apply(pd.to_numeric, errors='coerce')
|
|
131
|
+
cur_df["team_id"] = team_id
|
|
132
|
+
cur_df["player_id"] = player_id
|
|
133
|
+
cur_df["player_name"] = player_name
|
|
134
|
+
cur_df["side_1h"] = side_1h
|
|
135
|
+
|
|
136
|
+
df = pd.concat([df, cur_df], ignore_index=True)
|
|
137
|
+
|
|
138
|
+
return df.sort_values(by=["second", "team_id", "player_id"])
|
|
139
|
+
|
|
105
140
|
def get_match_stats(self, match_id: int) -> dict:
|
|
106
141
|
data = self.resp2data(
|
|
107
|
-
|
|
142
|
+
self.urls["match_stats"].format(
|
|
108
143
|
user=self.user,
|
|
109
144
|
password=self.password,
|
|
110
145
|
match_id=match_id
|
|
@@ -2,5 +2,6 @@ URLs = {
|
|
|
2
2
|
"schedule": "http://feeds.rustatsport.ru/?tpl=35&user={user}&key={password}&team_id={team_id}&season_id={season_id}&date_start=&date_end=&format=json",
|
|
3
3
|
"events": "http://feeds.rustatsport.ru/?tpl=36&user={user}&key={password}&match_id={match_id}&start_ms=0&dl=0&lang_id=1&format=json",
|
|
4
4
|
"match_stats": "http://feeds.rustatsport.ru/?tpl=207&user={user}&key={password}&match_id={match_id}&lang_id=1&format=json",
|
|
5
|
-
"tournament_teams": "http://feeds.rustatsport.ru/?tpl=32&user={user}&key={password}&tournament_id=2&season_id={season_id}&date_start=&date_end=&lang_id=1&format=json"
|
|
5
|
+
"tournament_teams": "http://feeds.rustatsport.ru/?tpl=32&user={user}&key={password}&tournament_id=2&season_id={season_id}&date_start=&date_end=&lang_id=1&format=json",
|
|
6
|
+
"tracking": "https://feeds.rustatsport.ru/?tpl=274&user={user}&key={password}&match_id={match_id}&lang_id=0&format=json"
|
|
6
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rustat-python-api
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A Python wrapper for RuStat API
|
|
5
5
|
Home-page: https://github.com/dailydaniel/rustat-python-api
|
|
6
6
|
Author: Daniel Zholkovsky
|
|
@@ -41,4 +41,6 @@ match_id = keys[-1]
|
|
|
41
41
|
events = parser.get_events(match_id)
|
|
42
42
|
|
|
43
43
|
stats = parser.get_match_stats(match_id)
|
|
44
|
+
|
|
45
|
+
tracking = parser.get_tracking(match_id)
|
|
44
46
|
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{rustat-python-api-0.1.1 → rustat-python-api-0.1.2}/rustat_python_api.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|