more prints

This commit is contained in:
2026-02-19 15:54:20 +01:00
parent e3bc11a632
commit 542ae9a35a

View File

@@ -28,6 +28,7 @@ async def get_latest_post(subreddit):
headers = {"User-Agent": "Mozilla/5.0 (compatible; ich_iel-Bot/0.1)"}
response = requests.get(url, headers=headers)
if response.status_code == 200:
if response.headers.get("Content-Type", "").startswith("application/json"):
try:
data = response.json()
print(f"Fetched data from Reddit: {data}")
@@ -39,6 +40,10 @@ async def get_latest_post(subreddit):
return post["title"], post["url"]
except (KeyError, json.JSONDecodeError):
return None, None
else:
print(f"Unexpected content type from Reddit: {response.headers.get('Content-Type')}")
print(f"Response content: {response.text}")
return None, None
else:
print(f"Failed to fetch Reddit data (maybe a block?): {response.status_code}")
return None, None