Skip to main content

pyq3serverlist

ci License Package Last commit

Simple Python 🐍 library for querying Quake 3 based principal servers and their game servers. Very much based on jacklul's PHP implementation.

Features

  • retrieve a list of game servers from a Quake 3 principal ("master") server
  • supports both UDP (default) and TCP for server list retrieval
  • retrieve status details and current players from game servers

Installation

Simply install the package via pip.

$ pip install pyq3serverlist

Usage

The following example retrieves and prints a game server list for Call of Duty 4: Modern Warfare directly from Activision via UDP.

from pyq3serverlist import PrincipalServer, PyQ3SLError, PyQ3SLTimeoutError

principal = PrincipalServer('cod4master.activision.com', 20810)

try:
    servers = principal.get_servers(6)
    print(servers)
except (PyQ3SLError, PyQ3SLTimeoutError) as e:
    print(e)

Longer server lists are usually split into multiple packets. Unfortunately, some principal servers implemented the Quake3 protocol without any indication of whether the response consists of multiple packets. For these principal servers (e.g. master.quake3arena.com, *.idsoftware.com, master0.etmaster.net), we need to keep reading packets until a read attempt times out.

To enable this behavior, use the TimeoutReader instead of the default EOFReader.

from pyq3serverlist import PrincipalServer, TimeoutReader, PyQ3SLError, PyQ3SLTimeoutError

principal = PrincipalServer('master.quake3arena.com', 27950, reader=TimeoutReader())

try:
    servers = principal.get_servers(68)
    print(servers)
except (PyQ3SLError, PyQ3SLTimeoutError) as e:
    print(e)

If you want to query a specific server, initialize a game server object for a known server directly and query its status.

from pyq3serverlist import Server, PyQ3SLError, PyQ3SLTimeoutError

server = Server('198.144.177.2', 27963)
try:
    info = server.get_status()
    print(info)
except (PyQ3SLError, PyQ3SLTimeoutError) as e:
    print(e)

Medal of Honor: Allied Assault, Medal of Honor: Allied Assault Spearhead, Medal of Honor: Allied Assault Breakthrough and Medal of Honor: Pacific Assault all use GameSpy for listing server and support the GameSpy1 query protocol. They do, however, also support a Quake3 protocol variant, which allows queries via the game port.

You can query any known game server for the mentioned Medal of Honor games using MedalOfHonorServer instead of Server.

from pyq3serverlist import MedalOfHonorServer, PyQ3SLError, PyQ3SLTimeoutError

server = MedalOfHonorServer('217.247.241.12', 12203)
try:
    info = server.get_status()
    print(info)
except (PyQ3SLError, PyQ3SLTimeoutError) as e:
    print(e)

You can find a few more examples in the examples folder.

Metadata

Release files for pyq3serverlist 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyq3serverlist 0.4.0
File Size Uploaded
pyq3serverlist-0.4.0.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyq3serverlist 0.4.0
File Interpreter ABI Platform
pyq3serverlist-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / pyq3serverlist-0.4.0.tar.gz

Download URL pyq3serverlist-0.4.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3bdf109a34577a261d14cfe4bb5233f8d6918cb0bc5e6cffeba71348e0972546
BLAKE2b-256 checksum
How to use checksums
03c3cd56bfadc53b2fa813d015c8e8738e9726f0cd5d6d22d1b263d00fdd5777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / pyq3serverlist-0.4.0-py3-none-any.whl

Download URL pyq3serverlist-0.4.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e311726f78ad0405370b4461eb64dd3a4872340a84c9a0de92c568f742c33659
BLAKE2b-256 checksum
How to use checksums
e46b01a092887c40fa182e7f308e61a4b661624b83e8d72ef2df38dff1e59365
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page