allow multiple image types
All checks were successful
Docker Image / build (push) Successful in 1m5s

This commit is contained in:
LockeShor
2026-03-02 18:43:27 -05:00
parent 7471c3d36d
commit a3290d1d15

View File

@@ -265,8 +265,13 @@ def build_storj_screenshot_urls(session: requests.Session, app_id: str) -> List[
return [] return []
screenshot_urls: List[str] = [] screenshot_urls: List[str] = []
image_extensions = ["png", "jpg", "jpeg", "webp"]
for index in range(1, MAX_SCREENSHOTS_PER_APP + 1): for index in range(1, MAX_SCREENSHOTS_PER_APP + 1):
screenshot_url = f"{MEDIA_BASE_URL.rstrip('/')}/apps/{app_id}/screenshots/screenshot{index}.png" matched_for_index = False
for extension in image_extensions:
screenshot_url = (
f"{MEDIA_BASE_URL.rstrip('/')}/apps/{app_id}/screenshots/screenshot{index}.{extension}"
)
try: try:
response = session.get( response = session.get(
screenshot_url, screenshot_url,
@@ -274,16 +279,21 @@ def build_storj_screenshot_urls(session: requests.Session, app_id: str) -> List[
headers={"User-Agent": USER_AGENT}, headers={"User-Agent": USER_AGENT},
) )
except requests.RequestException: except requests.RequestException:
break continue
if response.status_code != 200: if response.status_code != 200:
break continue
content_type = str(response.headers.get("Content-Type", "")).lower() content_type = str(response.headers.get("Content-Type", "")).lower()
if content_type and "image" not in content_type: if content_type and "image" not in content_type:
break continue
screenshot_urls.append(screenshot_url) screenshot_urls.append(screenshot_url)
matched_for_index = True
break
if not matched_for_index:
break
return screenshot_urls return screenshot_urls