python-ballchasing 0.2.0__tar.gz → 0.4.0__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.
- python_ballchasing-0.4.0/PKG-INFO +108 -0
- python_ballchasing-0.4.0/README.md +91 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/ballchasing/__init__.py +7 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/ballchasing/api.py +207 -119
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/ballchasing/constants.py +68 -47
- python_ballchasing-0.4.0/ballchasing/typed/__init__.py +5 -0
- python_ballchasing-0.4.0/ballchasing/typed/deep_group.py +440 -0
- python_ballchasing-0.4.0/ballchasing/typed/deep_replay.py +286 -0
- python_ballchasing-0.4.0/ballchasing/typed/shallow_group.py +18 -0
- python_ballchasing-0.4.0/ballchasing/typed/shallow_replay.py +67 -0
- python_ballchasing-0.4.0/ballchasing/typed/shared.py +218 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/ballchasing/util.py +16 -4
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/pyproject.toml +2 -2
- python_ballchasing-0.4.0/python_ballchasing.egg-info/PKG-INFO +108 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/python_ballchasing.egg-info/SOURCES.txt +10 -1
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/python_ballchasing.egg-info/top_level.txt +1 -0
- python_ballchasing-0.4.0/scripts/make_types.py +194 -0
- python_ballchasing-0.4.0/scripts/test.py +52 -0
- python_ballchasing-0.4.0/scripts/test_typed.py +35 -0
- python_ballchasing-0.2.0/PKG-INFO +0 -36
- python_ballchasing-0.2.0/README.md +0 -19
- python_ballchasing-0.2.0/python_ballchasing.egg-info/PKG-INFO +0 -36
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/LICENSE +0 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/ballchasing/stats_info.tsv +0 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/python_ballchasing.egg-info/dependency_links.txt +0 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/python_ballchasing.egg-info/requires.txt +0 -0
- {python_ballchasing-0.2.0 → python_ballchasing-0.4.0}/setup.cfg +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-ballchasing
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: A Python wrapper around the Ballchasing API
|
|
5
|
+
Author-email: Rolv-Arild Braaten <rolv_arild@hotmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
Project-URL: Homepage, https://github.com/Rolv-Arild/python-ballchasing
|
|
8
|
+
Project-URL: Download, https://pypi.python.org/pypi/python-ballchasing
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# Python Ballchasing
|
|
19
|
+
An easy-to-use and comprehensive Python wrapper for the [ballchasing.com API](https://ballchasing.com/doc/api).
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
You can install the library from PyPI using pip:
|
|
23
|
+
```
|
|
24
|
+
pip install python-ballchasing
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Authentication
|
|
28
|
+
Before you can use the library, you need an API authentication key from ballchasing.com.
|
|
29
|
+
1. Log in to [ballchasing.com](https://ballchasing.com/).
|
|
30
|
+
2. Navigate to the Upload tab.
|
|
31
|
+
3. Create an API key and copy it.
|
|
32
|
+
|
|
33
|
+
**Keep your API key secure and do not share it publicly.**
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
For detailed information, please refer to the docs inside the code. For the most part it follows the API spec closely, but there are some differences.
|
|
37
|
+
|
|
38
|
+
The API is exposed via the `BallchasingApi` class.
|
|
39
|
+
|
|
40
|
+
Making the client:
|
|
41
|
+
```python
|
|
42
|
+
from ballchasing import BallchasingApi
|
|
43
|
+
api = BallchasingApi("Your token here")
|
|
44
|
+
```
|
|
45
|
+
or equivalently
|
|
46
|
+
```python
|
|
47
|
+
import ballchasing
|
|
48
|
+
api = ballchasing.Api("Your token here")
|
|
49
|
+
```
|
|
50
|
+
By default this will also ping the API to make sure it's working.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
Some simple examples:
|
|
54
|
+
```python
|
|
55
|
+
# Get lots of SSL replays
|
|
56
|
+
|
|
57
|
+
from ballchasing import Rank # there's also Playlist, Season, Map, and more
|
|
58
|
+
|
|
59
|
+
replays = api.get_replays(
|
|
60
|
+
min_rank=Rank.SUPERSONIC_LEGEND,
|
|
61
|
+
count=10_000 # The API limits you to 200 replays per request but the library handles this for you
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
for replay in replays: # (replays is an iterable so you don't need to wait for all the replays to be collected)
|
|
65
|
+
... # Do something with the replays
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
# Get a specific replay with more detail than the iterator (including stats!)
|
|
70
|
+
replay = api.get_replay("2627e02a-aa46-4e13-b66b-b76a32069a07")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
# Get groups by the "RLCS Referee" account
|
|
75
|
+
groups = api.get_groups(creator="76561199225615730")
|
|
76
|
+
|
|
77
|
+
for group in groups:
|
|
78
|
+
# Download the group
|
|
79
|
+
api.download_group(
|
|
80
|
+
group_id=group["id"],
|
|
81
|
+
folder="/path/to/destination/"
|
|
82
|
+
recursive=True, # To download all the replays and retain the group structure with subfolders
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Get replays from the group
|
|
86
|
+
replays = get_group_replays(
|
|
87
|
+
group_id=group["id"],
|
|
88
|
+
deep=True, # To get detailed replay info
|
|
89
|
+
)
|
|
90
|
+
for replay in replays:
|
|
91
|
+
api.download_replay(replay_id=replay["id"], folder="/path/to/destination/") # You could also download like this
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Additionally, there's the option to put responses (replays, groups) into typed objects for better type hinting and validation.
|
|
95
|
+
It also attempts to fill in missing variables not returned by ballchasing (e.g. if a team has 0 goals they won't have a "goal" entry in the response)
|
|
96
|
+
The classes can also be found under the `typing` folder and used as a reference for what the API returns.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
# When creating the API, you can specify a default setting for typing (defaults to False)
|
|
100
|
+
api = ballchasing.Api("Your token here", typed=True)
|
|
101
|
+
|
|
102
|
+
# or you can specify it explicitly
|
|
103
|
+
replay = api.get_replay("2627e02a-aa46-4e13-b66b-b76a32069a07", typed=True)
|
|
104
|
+
print(replay.blue.players[0].name) # Example of easy attribute access
|
|
105
|
+
|
|
106
|
+
group = api.get_group("g2-vs-bds-hwbf2eyolb", typed=True)
|
|
107
|
+
print(group.players[0].name)
|
|
108
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Python Ballchasing
|
|
2
|
+
An easy-to-use and comprehensive Python wrapper for the [ballchasing.com API](https://ballchasing.com/doc/api).
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
You can install the library from PyPI using pip:
|
|
6
|
+
```
|
|
7
|
+
pip install python-ballchasing
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Authentication
|
|
11
|
+
Before you can use the library, you need an API authentication key from ballchasing.com.
|
|
12
|
+
1. Log in to [ballchasing.com](https://ballchasing.com/).
|
|
13
|
+
2. Navigate to the Upload tab.
|
|
14
|
+
3. Create an API key and copy it.
|
|
15
|
+
|
|
16
|
+
**Keep your API key secure and do not share it publicly.**
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
For detailed information, please refer to the docs inside the code. For the most part it follows the API spec closely, but there are some differences.
|
|
20
|
+
|
|
21
|
+
The API is exposed via the `BallchasingApi` class.
|
|
22
|
+
|
|
23
|
+
Making the client:
|
|
24
|
+
```python
|
|
25
|
+
from ballchasing import BallchasingApi
|
|
26
|
+
api = BallchasingApi("Your token here")
|
|
27
|
+
```
|
|
28
|
+
or equivalently
|
|
29
|
+
```python
|
|
30
|
+
import ballchasing
|
|
31
|
+
api = ballchasing.Api("Your token here")
|
|
32
|
+
```
|
|
33
|
+
By default this will also ping the API to make sure it's working.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
Some simple examples:
|
|
37
|
+
```python
|
|
38
|
+
# Get lots of SSL replays
|
|
39
|
+
|
|
40
|
+
from ballchasing import Rank # there's also Playlist, Season, Map, and more
|
|
41
|
+
|
|
42
|
+
replays = api.get_replays(
|
|
43
|
+
min_rank=Rank.SUPERSONIC_LEGEND,
|
|
44
|
+
count=10_000 # The API limits you to 200 replays per request but the library handles this for you
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
for replay in replays: # (replays is an iterable so you don't need to wait for all the replays to be collected)
|
|
48
|
+
... # Do something with the replays
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
# Get a specific replay with more detail than the iterator (including stats!)
|
|
53
|
+
replay = api.get_replay("2627e02a-aa46-4e13-b66b-b76a32069a07")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
# Get groups by the "RLCS Referee" account
|
|
58
|
+
groups = api.get_groups(creator="76561199225615730")
|
|
59
|
+
|
|
60
|
+
for group in groups:
|
|
61
|
+
# Download the group
|
|
62
|
+
api.download_group(
|
|
63
|
+
group_id=group["id"],
|
|
64
|
+
folder="/path/to/destination/"
|
|
65
|
+
recursive=True, # To download all the replays and retain the group structure with subfolders
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Get replays from the group
|
|
69
|
+
replays = get_group_replays(
|
|
70
|
+
group_id=group["id"],
|
|
71
|
+
deep=True, # To get detailed replay info
|
|
72
|
+
)
|
|
73
|
+
for replay in replays:
|
|
74
|
+
api.download_replay(replay_id=replay["id"], folder="/path/to/destination/") # You could also download like this
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Additionally, there's the option to put responses (replays, groups) into typed objects for better type hinting and validation.
|
|
78
|
+
It also attempts to fill in missing variables not returned by ballchasing (e.g. if a team has 0 goals they won't have a "goal" entry in the response)
|
|
79
|
+
The classes can also be found under the `typing` folder and used as a reference for what the API returns.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
# When creating the API, you can specify a default setting for typing (defaults to False)
|
|
83
|
+
api = ballchasing.Api("Your token here", typed=True)
|
|
84
|
+
|
|
85
|
+
# or you can specify it explicitly
|
|
86
|
+
replay = api.get_replay("2627e02a-aa46-4e13-b66b-b76a32069a07", typed=True)
|
|
87
|
+
print(replay.blue.players[0].name) # Example of easy attribute access
|
|
88
|
+
|
|
89
|
+
group = api.get_group("g2-vs-bds-hwbf2eyolb", typed=True)
|
|
90
|
+
print(group.players[0].name)
|
|
91
|
+
```
|