webmazta commited on
Commit ·
276a8ca
1
Parent(s): a9a9cc5
debug: add response logging and cache-busting to video upload
Browse files
main.py
CHANGED
|
@@ -1360,11 +1360,16 @@ def upload_media_to_wp(file_path: Path, filename: str = None) -> dict:
|
|
| 1360 |
data=f,
|
| 1361 |
auth=_wp_auth(),
|
| 1362 |
timeout=timeout,
|
| 1363 |
-
allow_redirects=True
|
|
|
|
| 1364 |
)
|
| 1365 |
|
| 1366 |
# Check if we got a bot verification page instead of a response
|
| 1367 |
content_type = response.headers.get("Content-Type", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1368 |
if "text/html" in content_type or "<html" in response.text.lower() or "bot verification" in response.text.lower():
|
| 1369 |
raise Exception(
|
| 1370 |
f"WordPress blocked the upload (bot verification/WAF). "
|
|
|
|
| 1360 |
data=f,
|
| 1361 |
auth=_wp_auth(),
|
| 1362 |
timeout=timeout,
|
| 1363 |
+
allow_redirects=True,
|
| 1364 |
+
params={"_cache_bust": str(int(time.time()))} # Bypass CDN/cache
|
| 1365 |
)
|
| 1366 |
|
| 1367 |
# Check if we got a bot verification page instead of a response
|
| 1368 |
content_type = response.headers.get("Content-Type", "")
|
| 1369 |
+
print(f" [DEBUG] Upload response: Status={response.status_code}, Content-Type={content_type}, URL={response.url}")
|
| 1370 |
+
if response.status_code == 200 and "text/html" in content_type:
|
| 1371 |
+
print(f" [DEBUG] HTML Response preview: {response.text[:300]}")
|
| 1372 |
+
|
| 1373 |
if "text/html" in content_type or "<html" in response.text.lower() or "bot verification" in response.text.lower():
|
| 1374 |
raise Exception(
|
| 1375 |
f"WordPress blocked the upload (bot verification/WAF). "
|