From b71fa0e414f1d3bf6c6e2ca33ad3fac4d3772b4c Mon Sep 17 00:00:00 2001 From: Abe Binder Date: Tue, 3 Feb 2026 21:33:48 -1000 Subject: [PATCH] Fix loading screenshots from Debian. --- usr/lib/linuxmint/mintinstall/imaging.py | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/usr/lib/linuxmint/mintinstall/imaging.py b/usr/lib/linuxmint/mintinstall/imaging.py index cec7166..98aa947 100644 --- a/usr/lib/linuxmint/mintinstall/imaging.py +++ b/usr/lib/linuxmint/mintinstall/imaging.py @@ -1,10 +1,9 @@ #!/usr/bin/python3 import os -import threading import requests import urllib -import re +import json import logging from concurrent.futures import ThreadPoolExecutor @@ -261,20 +260,22 @@ def _download_screenshots_thread(self): try: # Add additional screenshots from Debian - from bs4 import BeautifulSoup - page = BeautifulSoup(urllib.request.urlopen("https://screenshots.debian.net/package/%s" % self.pkginfo.name, timeout=5), "lxml") - images = page.findAll(href=re.compile(r"/shrine/screenshot[/\d\w]*large-[\w\d]*.png")) - for image in images: + json_url = "https://screenshots.debian.net/json/package/%s" % self.pkginfo.name + response = requests.get(json_url, timeout=5) + response.raise_for_status() + data = json.loads(response.text) + + screenshots = data.get("screenshots", []) + for screenshot in screenshots: if num_screenshots >= 4: break - num_screenshots += 1 - - thumb = "https://screenshots.debian.net%s" % image['href'] - local_name = os.path.join(SCREENSHOT_DIR, "%s_%s.png" % (self.pkginfo.name, num_screenshots)) - self.save_to_file(thumb, None, local_name) - - self.add_screenshot(self.pkginfo, local_name, num_screenshots) + screenshot_url = screenshot.get("screenshot_image_url") + if screenshot_url: + num_screenshots += 1 + local_name = os.path.join(SCREENSHOT_DIR, "%s_%s.png" % (self.pkginfo.name, num_screenshots)) + self.save_to_file(screenshot_url, None, local_name) + self.add_screenshot(self.pkginfo, local_name, num_screenshots) except Exception as e: pass