Fixing ubuntu

This commit is contained in:
Kasper Plougmann 2025-07-08 20:46:59 +02:00 committed by GitHub
parent 203b9468fd
commit f212bb6e43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,23 +37,20 @@ def download_torrent(name, url):
def fetch_ubuntu_lts(): def fetch_ubuntu_lts():
url = "https://releases.ubuntu.com/" url = "https://releases.ubuntu.com/"
try: try:
r = requests.get(url, timeout=30) text = requests.get("https://changelogs.ubuntu.com/meta-release-lts", timeout=30).text
r.raise_for_status() blocks = [b for b in text.strip().split("\n\n") if "Supported: 1" in b]
soup = BeautifulSoup(r.text, "html.parser") results = {}
lts_versions = [] # newest first (optional remove reversed() if order is irrelevant)
for link in soup.find_all('a', href=True): for block in reversed(blocks):
href = link['href'] version = re.search(r"Version:\s*([\d.]+)", block).group(1)
if re.match(r"^\d{2}\.\d{2}/$", href) and "lts" in link.text.lower(): codename = re.search(r"Dist:\s*(\w+)", block).group(1)
lts_versions.append(href.strip("/"))
if not lts_versions: results[f"ubuntu-{version}-desktop"] = download_torrent(f"ubuntu-{version}-desktop", f"https://releases.ubuntu.com/{codename}/ubuntu-{version}-desktop-amd64.iso.torrent")
logging.warning("No Ubuntu LTS versions found.") results[f"ubuntu-{version}-live-server"] = download_torrent(f"ubuntu-{version}-live-server", f"https://releases.ubuntu.com/{codename}/ubuntu-{version}-live-server-amd64.iso.torrent")
return False results[f"lbuntu-{version}-desktop"] = download_torrent(f"lbuntu-{version}-desktop", f"https://cdimage.ubuntu.com/lubuntu/releases/{codename}/release/lubuntu-{version}-desktop-amd64.iso.torrent")
latest_lts = sorted(lts_versions, reverse=True)[0] return results
torrent_url = f"https://releases.ubuntu.com/{latest_lts}/ubuntu-{latest_lts}-desktop-amd64.iso.torrent"
return download_torrent(f"ubuntu-{latest_lts}", torrent_url)
except Exception as e: except Exception as e:
logging.error(f"Ubuntu fetch error: {e}") logging.error(f"Ubuntu fetch error: {e}")
return False return False