mc5-api-client 1.0.18__py3-none-any.whl → 1.0.20__py3-none-any.whl
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.
- mc5_api_client/__init__.py +5 -1
- mc5_api_client/client.py +68 -15
- {mc5_api_client-1.0.18.dist-info → mc5_api_client-1.0.20.dist-info}/METADATA +102 -6
- {mc5_api_client-1.0.18.dist-info → mc5_api_client-1.0.20.dist-info}/RECORD +8 -8
- {mc5_api_client-1.0.18.dist-info → mc5_api_client-1.0.20.dist-info}/WHEEL +0 -0
- {mc5_api_client-1.0.18.dist-info → mc5_api_client-1.0.20.dist-info}/entry_points.txt +0 -0
- {mc5_api_client-1.0.18.dist-info → mc5_api_client-1.0.20.dist-info}/licenses/LICENSE +0 -0
- {mc5_api_client-1.0.18.dist-info → mc5_api_client-1.0.20.dist-info}/top_level.txt +0 -0
mc5_api_client/__init__.py
CHANGED
|
@@ -15,7 +15,7 @@ messaging, and more.
|
|
|
15
15
|
|
|
16
16
|
from typing import Optional, Dict, Any
|
|
17
17
|
|
|
18
|
-
__version__ = "1.0.
|
|
18
|
+
__version__ = "1.0.20"
|
|
19
19
|
__author__ = "Chizoba"
|
|
20
20
|
__email__ = "chizoba2026@hotmail.com"
|
|
21
21
|
__license__ = "MIT"
|
|
@@ -87,6 +87,9 @@ from .client import MC5Client
|
|
|
87
87
|
from .auth import TokenGenerator
|
|
88
88
|
from .exceptions import MC5APIError, AuthenticationError, RateLimitError
|
|
89
89
|
from .help import help, examples, quick_reference
|
|
90
|
+
|
|
91
|
+
# Add MC5ApiClient as an alias for backward compatibility
|
|
92
|
+
MC5ApiClient = MC5Client
|
|
90
93
|
from .admin_client import (
|
|
91
94
|
AdminMC5Client,
|
|
92
95
|
create_admin_client,
|
|
@@ -322,6 +325,7 @@ def encrypt_token(
|
|
|
322
325
|
|
|
323
326
|
__all__ = [
|
|
324
327
|
"MC5Client",
|
|
328
|
+
"MC5ApiClient",
|
|
325
329
|
"SimpleMC5Client",
|
|
326
330
|
"AdminMC5Client",
|
|
327
331
|
"batch_search_players",
|
mc5_api_client/client.py
CHANGED
|
@@ -1573,31 +1573,84 @@ class MC5Client(SquadBattleMixin, FederationMixin, AlertsMixin, AccountMixin, Tr
|
|
|
1573
1573
|
|
|
1574
1574
|
# Utility Methods
|
|
1575
1575
|
|
|
1576
|
-
def
|
|
1576
|
+
def close(self):
|
|
1577
|
+
"""Close the HTTP session and cleanup resources."""
|
|
1578
|
+
if self.session:
|
|
1579
|
+
self.session.close()
|
|
1580
|
+
if self.token_generator:
|
|
1581
|
+
self.token_generator.close()
|
|
1582
|
+
|
|
1583
|
+
# Server Status Methods (for compatibility)
|
|
1584
|
+
|
|
1585
|
+
def get_server_status(self) -> Dict[str, Any]:
|
|
1577
1586
|
"""
|
|
1578
|
-
Get
|
|
1587
|
+
Get server status information.
|
|
1579
1588
|
|
|
1580
1589
|
Returns:
|
|
1581
|
-
|
|
1590
|
+
Dictionary with server status
|
|
1582
1591
|
"""
|
|
1583
|
-
|
|
1584
|
-
|
|
1592
|
+
try:
|
|
1593
|
+
# Try to get events as a basic connectivity test
|
|
1594
|
+
events = self.get_events()
|
|
1595
|
+
return {
|
|
1596
|
+
"status": "online",
|
|
1597
|
+
"message": "MC5 servers are online",
|
|
1598
|
+
"events_count": len(events),
|
|
1599
|
+
"timestamp": time.time()
|
|
1600
|
+
}
|
|
1601
|
+
except Exception as e:
|
|
1602
|
+
return {
|
|
1603
|
+
"status": "offline",
|
|
1604
|
+
"message": f"Server status check failed: {str(e)}",
|
|
1605
|
+
"timestamp": time.time()
|
|
1606
|
+
}
|
|
1585
1607
|
|
|
1586
|
-
def
|
|
1608
|
+
def get_online_players(self) -> Dict[str, Any]:
|
|
1587
1609
|
"""
|
|
1588
|
-
|
|
1610
|
+
Get online players information (estimated).
|
|
1589
1611
|
|
|
1590
1612
|
Returns:
|
|
1591
|
-
|
|
1613
|
+
Dictionary with online player count
|
|
1592
1614
|
"""
|
|
1593
|
-
|
|
1615
|
+
try:
|
|
1616
|
+
# Get events as a proxy for activity
|
|
1617
|
+
events = self.get_events()
|
|
1618
|
+
# This is an estimate - actual player count isn't directly available
|
|
1619
|
+
return {
|
|
1620
|
+
"online_players": "Unknown",
|
|
1621
|
+
"active_events": len(events),
|
|
1622
|
+
"message": "Player count not directly available via API",
|
|
1623
|
+
"timestamp": time.time()
|
|
1624
|
+
}
|
|
1625
|
+
except Exception as e:
|
|
1626
|
+
return {
|
|
1627
|
+
"online_players": 0,
|
|
1628
|
+
"error": str(e),
|
|
1629
|
+
"timestamp": time.time()
|
|
1630
|
+
}
|
|
1594
1631
|
|
|
1595
|
-
def
|
|
1596
|
-
"""
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1632
|
+
def get_server_info(self) -> Dict[str, Any]:
|
|
1633
|
+
"""
|
|
1634
|
+
Get general server information.
|
|
1635
|
+
|
|
1636
|
+
Returns:
|
|
1637
|
+
Dictionary with server information
|
|
1638
|
+
"""
|
|
1639
|
+
try:
|
|
1640
|
+
return {
|
|
1641
|
+
"server": "Modern Combat 5",
|
|
1642
|
+
"region": "Europe",
|
|
1643
|
+
"api_version": "1.0.18",
|
|
1644
|
+
"endpoints": list(self.BASE_URLS.keys()),
|
|
1645
|
+
"client_id": self.client_id,
|
|
1646
|
+
"authenticated": bool(self.access_token),
|
|
1647
|
+
"timestamp": time.time()
|
|
1648
|
+
}
|
|
1649
|
+
except Exception as e:
|
|
1650
|
+
return {
|
|
1651
|
+
"error": str(e),
|
|
1652
|
+
"timestamp": time.time()
|
|
1653
|
+
}
|
|
1601
1654
|
|
|
1602
1655
|
# Events API
|
|
1603
1656
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mc5_api_client
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.20
|
|
4
4
|
Summary: A comprehensive Python library for interacting with the Modern Combat 5 API
|
|
5
5
|
Home-page: https://pypi.org/project/mc5-api-client/
|
|
6
6
|
Author: Chizoba
|
|
@@ -143,10 +143,109 @@ Think of this as your remote control for Modern Combat 5! Here's what you can do
|
|
|
143
143
|
### 🎉 MC5 API Client v1.0.18 - Super Easy Interface & Clean API!
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
|
-
pip install mc5_api_client==1.0.
|
|
146
|
+
pip install mc5_api_client==1.0.20
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
## 🎯 **Usage Examples**
|
|
150
|
+
|
|
151
|
+
### **🎮 Basic Usage (MC5Client)**
|
|
152
|
+
```python
|
|
153
|
+
from mc5_api_client import MC5Client
|
|
154
|
+
|
|
155
|
+
# Initialize the client
|
|
156
|
+
client = MC5Client(
|
|
157
|
+
client_id="1875:55979:6.0.0a:windows:windows",
|
|
158
|
+
username="your_credential",
|
|
159
|
+
password="your_password"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Authenticate
|
|
163
|
+
client.authenticate()
|
|
164
|
+
|
|
165
|
+
# Get profile
|
|
166
|
+
profile = client.get_profile()
|
|
167
|
+
print(f"Profile: {profile}")
|
|
168
|
+
|
|
169
|
+
# Get events
|
|
170
|
+
events = client.get_events()
|
|
171
|
+
print(f"Events: {len(events)} found")
|
|
172
|
+
|
|
173
|
+
# Server status (NEW!)
|
|
174
|
+
status = client.get_server_status()
|
|
175
|
+
print(f"Server Status: {status['status']}")
|
|
176
|
+
|
|
177
|
+
# Close connection
|
|
178
|
+
client.close()
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### **🎯 MC5ApiClient (Backward Compatible)**
|
|
182
|
+
```python
|
|
183
|
+
from mc5_api_client import MC5ApiClient
|
|
184
|
+
|
|
185
|
+
# MC5ApiClient is an alias for MC5Client
|
|
186
|
+
client = MC5ApiClient(
|
|
187
|
+
client_id="1875:55979:6.0.0a:windows:windows",
|
|
188
|
+
username="your_credential",
|
|
189
|
+
password="your_password"
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
# Use the same methods as MC5Client
|
|
193
|
+
client.authenticate()
|
|
194
|
+
status = client.get_server_status()
|
|
195
|
+
info = client.get_server_info()
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### **🔧 Quick Functions (Standalone)**
|
|
199
|
+
```python
|
|
200
|
+
from mc5_api_client import quick_get_account_info, quick_get_active_sessions
|
|
201
|
+
|
|
202
|
+
# Quick functions are standalone, not client methods
|
|
203
|
+
# They require credentials as parameters
|
|
204
|
+
account_info = quick_get_account_info("your_credential", "your_password")
|
|
205
|
+
sessions = quick_get_active_sessions("your_password")
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### **🎮 Game Launch & Service Location (NEW!)**
|
|
209
|
+
```python
|
|
210
|
+
from mc5_api_client import MC5Easy, get_all_services, create_federation_session
|
|
211
|
+
|
|
212
|
+
# Get all MC5 services dynamically
|
|
213
|
+
services = get_all_services()
|
|
214
|
+
print(f"Found {len(services)} services:")
|
|
215
|
+
for service, endpoint in services.items():
|
|
216
|
+
print(f" {service}: {endpoint}")
|
|
217
|
+
|
|
218
|
+
# Create federation session for game launch
|
|
219
|
+
session = create_federation_session(username, password)
|
|
220
|
+
if session.get("success"):
|
|
221
|
+
print(f"Room ID: {session['room_id']}")
|
|
222
|
+
print(f"Controller: {session['controller_host']}")
|
|
223
|
+
|
|
224
|
+
# Or use MC5Easy for complete game management
|
|
225
|
+
with MC5Easy(username, password) as mc5:
|
|
226
|
+
launch_info = mc5.launch_game_session()
|
|
227
|
+
print(f"Game ready: {launch_info['launch_command']}")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### **🌐 Global ID & Device Management (NEW!)**
|
|
231
|
+
```python
|
|
232
|
+
from mc5_api_client import get_global_id, generate_device_id
|
|
233
|
+
|
|
234
|
+
# Get global device ID
|
|
235
|
+
global_id = get_global_id()
|
|
236
|
+
print(f"Global ID: {global_id}")
|
|
237
|
+
|
|
238
|
+
# Generate unique device ID
|
|
239
|
+
device_id = generate_device_id()
|
|
240
|
+
print(f"Device ID: {device_id}")
|
|
241
|
+
|
|
242
|
+
# With MC5Easy
|
|
243
|
+
with MC5Easy(username, password) as mc5:
|
|
244
|
+
device_info = mc5.get_device_info()
|
|
245
|
+
print(f"Device: {device_info}")
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## 📱 **Run Examples:** Completed!
|
|
150
249
|
|
|
151
250
|
**🎯 Super Easy Interface (NEW in v1.0.18):**
|
|
152
251
|
- ✅ **MC5Easy Module** - One-line functions for everyday tasks
|
|
@@ -1348,8 +1447,6 @@ finally:
|
|
|
1348
1447
|
**Security Benefits:**
|
|
1349
1448
|
- ✅ **Additional Layer**: Tokens are encrypted before transmission
|
|
1350
1449
|
- ✅ **Custom Nonce**: Support for custom nonce values
|
|
1351
|
-
- ✅ **Backward Compatible**: Works with existing authentication flow
|
|
1352
|
-
- ✅ **Error Handling**: Proper validation and error recovery
|
|
1353
1450
|
|
|
1354
1451
|
### 🏆 **Checking Leaderboards**
|
|
1355
1452
|
|
|
@@ -1369,7 +1466,6 @@ if hasattr(client, 'get_leaderboard'):
|
|
|
1369
1466
|
# print(f"Top {len(leaderboard.get('players', []))} players")
|
|
1370
1467
|
else:
|
|
1371
1468
|
print("❌ get_leaderboard method not found")
|
|
1372
|
-
```
|
|
1373
1469
|
|
|
1374
1470
|
### 🖥️ CLI Commands - Currently Available
|
|
1375
1471
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
mc5_api_client/__init__.py,sha256=
|
|
1
|
+
mc5_api_client/__init__.py,sha256=lxGygRXrG6aUTZ_Em_TLyMzMxR7ylTXgXOhA5OEXfnM,11942
|
|
2
2
|
mc5_api_client/account.py,sha256=EmydXCsCXaKqMw21oVttQfYuDl50pa2dwhcTeHtnxbQ,14396
|
|
3
3
|
mc5_api_client/account_quick.py,sha256=t4ki4ujYENmcnd_004f0pO9SPxPyCllz4WHpBG9wNbo,10458
|
|
4
4
|
mc5_api_client/admin_client.py,sha256=527aavolxVhY2M5ceFxVbbE5YTczU9Z86Fdt1UzdRZM,15220
|
|
@@ -6,7 +6,7 @@ mc5_api_client/alerts.py,sha256=zW-cEwSSShuHkGxTBQaS8Ynf1a0hh5RMQ0G3WC_ajI0,1322
|
|
|
6
6
|
mc5_api_client/alerts_quick.py,sha256=D1j0RiHteYqoAgc4KYqTxYG1Hkud3b-xWRV_VOUEnY0,7946
|
|
7
7
|
mc5_api_client/auth.py,sha256=z8vmyQIHUdAzk0pUyKCesT8gTv4jboLIFGBxAu1v_-8,13396
|
|
8
8
|
mc5_api_client/cli.py,sha256=6xciRjWkUMOxgxlbDsoOiHRuirXPy7uc9WURXPKmgGc,17255
|
|
9
|
-
mc5_api_client/client.py,sha256=
|
|
9
|
+
mc5_api_client/client.py,sha256=EWL0IWiP9mwr9GTnnzWwTKHZUPe2LXaY7YxzjKTDjWM,112524
|
|
10
10
|
mc5_api_client/debug.py,sha256=524vNCE7jM_KP5JM81-3eI2cmFBBA-Hf7Uy0cIL75W0,8240
|
|
11
11
|
mc5_api_client/easy_mc5.py,sha256=kfjOJMW-VRAZcXEF1yHiGsACgjb-ZjXGuw1U_gepSQY,24202
|
|
12
12
|
mc5_api_client/exceptions.py,sha256=o7od4GrEIlgq6xSNUjZdh74xoDTytF3PLcMq5ewRiJw,2683
|
|
@@ -24,9 +24,9 @@ mc5_api_client/storage_admin.py,sha256=l-nwskbpa3KpeIoWcwVRicgBSvrTvQ5aE2QU_e366
|
|
|
24
24
|
mc5_api_client/telemetry.py,sha256=k8qOimPg-AKsnMclIgeqYCJ_97j2pWyiN7Lg80D4sKo,13246
|
|
25
25
|
mc5_api_client/transfer.py,sha256=-pln70360mo4cKBQIUzp_wt9ce1Cr4YA6aJDFPKEjzQ,14381
|
|
26
26
|
mc5_api_client/transfer_quick.py,sha256=HhRbp4FVzFwuzHDcqOyYiVjeVEIfgezlWd8SN6sh874,11310
|
|
27
|
-
mc5_api_client-1.0.
|
|
28
|
-
mc5_api_client-1.0.
|
|
29
|
-
mc5_api_client-1.0.
|
|
30
|
-
mc5_api_client-1.0.
|
|
31
|
-
mc5_api_client-1.0.
|
|
32
|
-
mc5_api_client-1.0.
|
|
27
|
+
mc5_api_client-1.0.20.dist-info/licenses/LICENSE,sha256=M0UBQ4B3pB9XcV54_jhVP681xyauF8GB6YK_rKmuXzk,1064
|
|
28
|
+
mc5_api_client-1.0.20.dist-info/METADATA,sha256=jcN6JTeojDPA5C_0U9l1_bCcwKNwkPNbf-1s17Uci3w,83121
|
|
29
|
+
mc5_api_client-1.0.20.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
30
|
+
mc5_api_client-1.0.20.dist-info/entry_points.txt,sha256=2kruOpleFYK3Jl1MoQwGyqCd-Pj4kQWngXmIjnXx_gE,48
|
|
31
|
+
mc5_api_client-1.0.20.dist-info/top_level.txt,sha256=eYJe4ue9j1ig_jFY5Z05mDqpizUEV7TYpk5lBXVd4kA,15
|
|
32
|
+
mc5_api_client-1.0.20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|