import urllib.request
import platform

system = platform.system().lower()
machine = platform.machine().lower()
is_arm = machine in ("arm64", "aarch64")

if system == "darwin":
    arch_str = "arm64" if is_arm else "amd64-compatible"
elif system == "linux":
    arch_str = "arm64" if is_arm else "amd64-compatible"

version = "v1.19.21"
url = f"https://github.com/MetaCubeX/mihomo/releases/download/{version}/mihomo-{system}-{arch_str}-{version}.gz"
print("URL:", url)

try:
    req = urllib.request.Request(url, method='HEAD')
    resp = urllib.request.urlopen(req, timeout=5)
    print("Status:", resp.status)
except Exception as e:
    print("Error:", e)
