Skip to content

Commit 2ba0433

Browse files
committed
Generates the StealthBot BNLS servers via BNETDocs
1 parent 399ac19 commit 2ba0433

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

bin/stealthbot_bnls_list.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import requests
2+
3+
# Dynamically retrieve the list of online BNLS servers from BNETDocs:
4+
url = 'https://bnetdocs.org/servers.json?type_id=20&status=1'
5+
6+
try:
7+
# Send GET request to retrieve server list
8+
response = requests.get(url)
9+
response.raise_for_status() # Raise error for bad status codes
10+
11+
# Check if the response content type starts with 'application/json'
12+
content_type = response.headers.get('Content-Type', '')
13+
if not content_type.startswith('application/json'):
14+
raise ValueError(f"Unexpected MIME type: {content_type}")
15+
16+
# Parse JSON data
17+
json_data = response.json()
18+
19+
except requests.exceptions.RequestException as e:
20+
print(f'Failed to download server list from: {url}\nError: {e}')
21+
except ValueError as ve:
22+
print(f'Error processing data: {ve}')
23+
else:
24+
# Add a blank line (based on original PHP script behavior)
25+
print()
26+
27+
# Print server addresses
28+
for server in json_data.get('servers', []):
29+
print(server['address'])
30+

0 commit comments

Comments
 (0)