bedrock support

This commit is contained in:
2026-03-11 23:29:13 +00:00
parent cf3e2c8c78
commit 28be3105b6
7 changed files with 200 additions and 10 deletions
+123
View File
@@ -0,0 +1,123 @@
"""
Minecraft Bedrock Edition version checker - tracks Windows releases
"""
import requests
import json
from datetime import datetime
# Bedrock version tracking endpoints
# Using third-party services that track Bedrock version history
BEDROCK_VERSIONS_URL = "https://raw.githubusercontent.com/pmmp/PocketMine-MP/master/src/VersionInfo.php"
# Alternative: Direct launcher check (if available)
BEDROCK_LAUNCHER_API = "https://launcher.mojang.com/v1/products/bedrock-launcher/latest"
TIMEOUT = 10
def get_bedrock_versions():
"""
Fetch Bedrock version information.
Attempts multiple sources for reliability.
Returns:
Dict with version info or None
"""
# Try the launcher API first
try:
response = requests.get(BEDROCK_LAUNCHER_API, timeout=TIMEOUT)
if response.status_code == 200:
data = response.json()
if data:
return data
except Exception as e:
print(f"[BEDROCK_CHECKER] Launcher API error: {e}")
# Fallback: try Windows version manifest
try:
# Query Microsoft's update service for Bedrock
response = requests.get(
"https://launcher.mojang.com/v1/products/bedrock-launcher/16/latest",
headers={"Accept": "application/json"},
timeout=TIMEOUT
)
if response.status_code == 200:
return response.json()
except Exception as e:
print(f"[BEDROCK_CHECKER] Manifest error: {e}")
return None
def parse_bedrock_version(response_data):
"""
Parse response data into standardized version format.
Args:
response_data: JSON response from version endpoint
Returns:
Dict with keys: id, version, type, releaseTime
"""
if not response_data:
return None
try:
# Extract version information from different possible response formats
version = response_data.get('version') or response_data.get('latest')
if not version:
return None
return {
"id": version,
"version": version,
"type": "bedrock-windows",
"releaseTime": response_data.get('releaseTime', datetime.utcnow().isoformat() + "+00:00"),
"platform": "windows"
}
except Exception as e:
print(f"[BEDROCK_CHECKER] Parse error: {e}")
return None
def get_latest_bedrock_release():
"""
Get the latest Bedrock Windows release.
Returns:
Dict with version info or None
"""
try:
version_data = get_bedrock_versions()
return parse_bedrock_version(version_data)
except Exception as e:
print(f"[BEDROCK_CHECKER] Error getting latest release: {e}")
return None
def compare_versions(v1, v2):
"""
Compare two version strings (semantic versioning).
Args:
v1, v2: Version strings like "1.20.0"
Returns:
True if v1 > v2, False otherwise
"""
try:
parts1 = [int(x) for x in v1.split('.')]
parts2 = [int(x) for x in v2.split('.')]
# Pad with zeros
while len(parts1) < len(parts2):
parts1.append(0)
while len(parts2) < len(parts1):
parts2.append(0)
return parts1 > parts2
except:
# Fallback to string comparison
return v1 > v2