python-ballchasing 0.1.22__tar.gz → 0.3.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.1.22 → python_ballchasing-0.3.0}/LICENSE +21 -21
- python_ballchasing-0.3.0/PKG-INFO +92 -0
- python_ballchasing-0.3.0/README.md +75 -0
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/ballchasing/__init__.py +67 -49
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/ballchasing/api.py +441 -444
- python_ballchasing-0.3.0/ballchasing/constants.py +223 -0
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/ballchasing/stats_info.tsv +142 -142
- python_ballchasing-0.3.0/ballchasing/util.py +100 -0
- python_ballchasing-0.3.0/pyproject.toml +32 -0
- python_ballchasing-0.3.0/python_ballchasing.egg-info/PKG-INFO +92 -0
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/python_ballchasing.egg-info/SOURCES.txt +1 -1
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/python_ballchasing.egg-info/top_level.txt +1 -0
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/setup.cfg +4 -4
- python-ballchasing-0.1.22/PKG-INFO +0 -37
- python-ballchasing-0.1.22/README.md +0 -21
- python-ballchasing-0.1.22/ballchasing/constants.py +0 -166
- python-ballchasing-0.1.22/ballchasing/util.py +0 -73
- python-ballchasing-0.1.22/python_ballchasing.egg-info/PKG-INFO +0 -37
- python-ballchasing-0.1.22/setup.py +0 -27
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/python_ballchasing.egg-info/dependency_links.txt +0 -0
- {python-ballchasing-0.1.22 → python_ballchasing-0.3.0}/python_ballchasing.egg-info/requires.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Rolv-Arild Braaten
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Rolv-Arild Braaten
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-ballchasing
|
|
3
|
+
Version: 0.3.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.8
|
|
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
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
```
|
|
@@ -1,49 +1,67 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# MIT License
|
|
3
|
-
#
|
|
4
|
-
# Copyright (c) 2020 Rolv-Arild Braaten
|
|
5
|
-
#
|
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
# furnished to do so, subject to the following conditions:
|
|
12
|
-
#
|
|
13
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
# copies or substantial portions of the Software.
|
|
15
|
-
#
|
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
# SOFTWARE.
|
|
23
|
-
|
|
24
|
-
"""A library that provides a Python interface to the Ballchasing API."""
|
|
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
|
-
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# MIT License
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2020 Rolv-Arild Braaten
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
# copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
# SOFTWARE.
|
|
23
|
+
|
|
24
|
+
"""A library that provides a Python interface to the Ballchasing API."""
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
# In Python 3.8+, importlib.metadata is in the standard library.
|
|
28
|
+
# For older versions, a backport is available as importlib_metadata.
|
|
29
|
+
if sys.version_info >= (3, 8):
|
|
30
|
+
from importlib.metadata import version, metadata
|
|
31
|
+
else:
|
|
32
|
+
from importlib_metadata import version, metadata
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
# This will read the version from the installed package's metadata
|
|
36
|
+
# (which is defined in pyproject.toml)
|
|
37
|
+
__version__ = version("python-ballchasing")
|
|
38
|
+
|
|
39
|
+
# You can also get other metadata in a similar way
|
|
40
|
+
pkg_metadata = metadata("python-ballchasing")
|
|
41
|
+
__author__ = pkg_metadata.get("Author-Email")
|
|
42
|
+
__description__ = pkg_metadata.get("Summary")
|
|
43
|
+
except Exception:
|
|
44
|
+
# If the package is not installed (e.g., when running in a development
|
|
45
|
+
# environment without an editable install), you can fall back to defaults.
|
|
46
|
+
__version__ = "0.0.0-dev"
|
|
47
|
+
__description__ = 'A Python wrapper around the Ballchasing API'
|
|
48
|
+
__author__ = 'Rolv-Arild Braaten <rolv_arild@hotmail.com>'
|
|
49
|
+
|
|
50
|
+
# Import the main classes and constants to make them easily accessible to users.
|
|
51
|
+
from .api import BallchasingApi
|
|
52
|
+
|
|
53
|
+
Api = BallchasingApi # For importing like `import ballchasing; api = ballchasing.Api`
|
|
54
|
+
|
|
55
|
+
from .constants import (
|
|
56
|
+
Playlist,
|
|
57
|
+
Rank,
|
|
58
|
+
Season,
|
|
59
|
+
MatchResult,
|
|
60
|
+
ReplaySortBy,
|
|
61
|
+
GroupSortBy,
|
|
62
|
+
SortDir,
|
|
63
|
+
Visibility,
|
|
64
|
+
PlayerIdentification,
|
|
65
|
+
TeamIdentification,
|
|
66
|
+
Map
|
|
67
|
+
)
|