Limit scan fallback to editor metadata
Browse files- backend/app.py +8 -6
backend/app.py
CHANGED
|
@@ -62,7 +62,7 @@ EXIF_TYPE_ORDER = (
|
|
| 62 |
)
|
| 63 |
EXIF_TYPE_TO_CODE = {name: idx + 1 for idx, name in enumerate(EXIF_TYPE_ORDER)}
|
| 64 |
EXIF_CODE_TO_TYPE = {idx + 1: name for idx, name in enumerate(EXIF_TYPE_ORDER)}
|
| 65 |
-
|
| 66 |
POST_SCAN_LIMIT = 64
|
| 67 |
EXIF_RANGE_LIMIT = 96
|
| 68 |
EXIF_RANGE_BYTES = 16384
|
|
@@ -1342,16 +1342,18 @@ async def scan_post(post_id, session, post_sem, exif_sem, img_sem):
|
|
| 1342 |
for url in image_urls:
|
| 1343 |
metadata = await get_exif_range(url, session, exif_sem)
|
| 1344 |
exif_type = determine_exif_type(metadata)
|
| 1345 |
-
if exif_type in
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1346 |
return post_id, url, EXIF_TYPE_TO_CODE.get(exif_type)
|
| 1347 |
-
if exif_type and fallback is None:
|
| 1348 |
-
fallback = post_id, url, EXIF_TYPE_TO_CODE.get(exif_type)
|
| 1349 |
-
if fallback:
|
| 1350 |
-
return fallback
|
| 1351 |
for url in image_urls:
|
| 1352 |
img_data = await fetch_image(session, url, img_sem)
|
| 1353 |
if img_data and has_stealth_png_bytes(img_data):
|
| 1354 |
return post_id, url, EXIF_TYPE_TO_CODE.get("stealth")
|
|
|
|
|
|
|
| 1355 |
return post_id, None, None
|
| 1356 |
except Exception:
|
| 1357 |
return post_id, None, None
|
|
|
|
| 62 |
)
|
| 63 |
EXIF_TYPE_TO_CODE = {name: idx + 1 for idx, name in enumerate(EXIF_TYPE_ORDER)}
|
| 64 |
EXIF_CODE_TO_TYPE = {idx + 1: name for idx, name in enumerate(EXIF_TYPE_ORDER)}
|
| 65 |
+
FALLBACK_EXIF_TYPES = {"celsys", "photoshop"}
|
| 66 |
POST_SCAN_LIMIT = 64
|
| 67 |
EXIF_RANGE_LIMIT = 96
|
| 68 |
EXIF_RANGE_BYTES = 16384
|
|
|
|
| 1342 |
for url in image_urls:
|
| 1343 |
metadata = await get_exif_range(url, session, exif_sem)
|
| 1344 |
exif_type = determine_exif_type(metadata)
|
| 1345 |
+
if exif_type in FALLBACK_EXIF_TYPES:
|
| 1346 |
+
if fallback is None:
|
| 1347 |
+
fallback = post_id, url, EXIF_TYPE_TO_CODE.get(exif_type)
|
| 1348 |
+
continue
|
| 1349 |
+
if exif_type:
|
| 1350 |
return post_id, url, EXIF_TYPE_TO_CODE.get(exif_type)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1351 |
for url in image_urls:
|
| 1352 |
img_data = await fetch_image(session, url, img_sem)
|
| 1353 |
if img_data and has_stealth_png_bytes(img_data):
|
| 1354 |
return post_id, url, EXIF_TYPE_TO_CODE.get("stealth")
|
| 1355 |
+
if fallback:
|
| 1356 |
+
return fallback
|
| 1357 |
return post_id, None, None
|
| 1358 |
except Exception:
|
| 1359 |
return post_id, None, None
|