Release 1.0.0

This commit is contained in:
2026-03-12 21:45:01 +00:00
parent 28be3105b6
commit b2a9f74f59
12 changed files with 1028 additions and 522 deletions
+85 -87
View File
@@ -1,99 +1,97 @@
"""
Minecraft Bedrock Edition version checker - tracks Windows releases
"""
import requests
import json
from bs4 import BeautifulSoup
import re
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.
"""Get the latest Bedrock edition version by scraping minecraft.wiki.
Returns:
Dict with version info or None
Parses the version history page to find the latest release.
Returns dict with id, version, type, releaseTime, or None if scraping fails.
"""
print("[BEDROCK_CHECKER] Fetching bedrock version from minecraft.wiki...")
try:
version_data = get_bedrock_versions()
return parse_bedrock_version(version_data)
url = "https://minecraft.wiki/w/Bedrock_Edition_version_history"
response = requests.get(url, timeout=10, headers={'User-Agent': 'MinecraftUpdateBot/1.0'})
if response.status_code != 200:
print(f"[BEDROCK_CHECKER] Failed to fetch wiki: {response.status_code}")
return None
soup = BeautifulSoup(response.content, 'html.parser')
# Find the first version number mentioned in the actual content
# Look for patterns like "26.3", "1.21.132", etc.
page_text = soup.get_text()
# The page structure has version numbers in tables
# Let's look for the section with "26.x" or "1.21" which are current
# Try to get version from table data
tables = soup.find_all('table', {"class": "wikitable"})
if tables:
for table in tables:
rows = table.find_all('tr')
if len(rows) > 1:
# Second row (first data row) has the latest version
cells = rows[1].find_all('td')
if cells:
version_text = cells[0].get_text(strip=True)
# Clean up the version text
if version_text and not version_text.lower().startswith('version'):
# Extract just the version number
version_match = re.match(r'^([\d.]+)', version_text)
if version_match:
version = version_match.group(1)
print(f"[BEDROCK_CHECKER] ✓ Found version from wiki table: {version}")
return {
"id": version,
"version": version,
"type": "bedrock-windows",
"source": "minecraft_wiki",
"releaseTime": datetime.now().isoformat()
}
# Fallback: parse page text for version patterns
# Look for the new versioning format (26.x, 27.x, etc.) - not old 1.21.x format
# New format is major.minor (e.g., 26.3, 27.0)
version_pattern = r'\b(2[6-9]|[3-9]\d)\.(\d{1,2})\b'
matches = re.findall(version_pattern, page_text)
if matches:
# Get the first match (oldest format would be 26.x, newest would be higher)
for major_str, minor_str in matches:
try:
major = int(major_str)
minor = int(minor_str)
# Accept versions 26.x and above
if major >= 26 and minor >= 0:
version = f"{major}.{minor}"
print(f"[BEDROCK_CHECKER] ✓ Found version from wiki: {version}")
return {
"id": version,
"version": version,
"type": "bedrock-windows",
"source": "minecraft_wiki",
"releaseTime": datetime.now().isoformat()
}
except ValueError:
continue
print("[BEDROCK_CHECKER] ✗ Could not find version number in wiki page")
return None
except requests.exceptions.Timeout:
print("[BEDROCK_CHECKER] ✗ Timeout fetching wiki page")
return None
except requests.exceptions.RequestException as e:
print(f"[BEDROCK_CHECKER] ✗ Request error: {e}")
return None
except Exception as e:
print(f"[BEDROCK_CHECKER] Error getting latest release: {e}")
print(f"[BEDROCK_CHECKER] Error scraping wiki: {e}")
return None