From a3290d1d150f9dc0b6627c749929be7bcc55278e Mon Sep 17 00:00:00 2001 From: LockeShor <75901583+LockeShor@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:43:27 -0500 Subject: [PATCH] allow multiple image types --- watcher.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/watcher.py b/watcher.py index 12930c1..36d44b4 100644 --- a/watcher.py +++ b/watcher.py @@ -265,26 +265,36 @@ def build_storj_screenshot_urls(session: requests.Session, app_id: str) -> List[ return [] screenshot_urls: List[str] = [] + image_extensions = ["png", "jpg", "jpeg", "webp"] for index in range(1, MAX_SCREENSHOTS_PER_APP + 1): - screenshot_url = f"{MEDIA_BASE_URL.rstrip('/')}/apps/{app_id}/screenshots/screenshot{index}.png" - try: - response = session.get( - screenshot_url, - timeout=REQUEST_TIMEOUT_SECONDS, - headers={"User-Agent": USER_AGENT}, + matched_for_index = False + for extension in image_extensions: + screenshot_url = ( + f"{MEDIA_BASE_URL.rstrip('/')}/apps/{app_id}/screenshots/screenshot{index}.{extension}" ) - except requests.RequestException: + try: + response = session.get( + screenshot_url, + timeout=REQUEST_TIMEOUT_SECONDS, + headers={"User-Agent": USER_AGENT}, + ) + except requests.RequestException: + continue + + if response.status_code != 200: + continue + + content_type = str(response.headers.get("Content-Type", "")).lower() + if content_type and "image" not in content_type: + continue + + screenshot_urls.append(screenshot_url) + matched_for_index = True break - if response.status_code != 200: + if not matched_for_index: break - content_type = str(response.headers.get("Content-Type", "")).lower() - if content_type and "image" not in content_type: - break - - screenshot_urls.append(screenshot_url) - return screenshot_urls