Update app.py
Browse files
app.py
CHANGED
|
@@ -286,42 +286,65 @@ def update_strategy_job():
|
|
| 286 |
log(step, f"Twitter fetch error: {te}")
|
| 287 |
twitter_summary = ""
|
| 288 |
|
| 289 |
-
# 2c) Capture chart screenshots
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
charts = [
|
| 291 |
{
|
| 292 |
-
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=&exchange=OANDA",
|
| 293 |
-
"timeframe": ""
|
|
|
|
|
|
|
|
|
|
| 294 |
},
|
| 295 |
-
|
| 296 |
{
|
| 297 |
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=15&exchange=OANDA",
|
| 298 |
-
"timeframe": "15 دقيقة"
|
|
|
|
|
|
|
|
|
|
| 299 |
},
|
| 300 |
{
|
| 301 |
-
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=
|
| 302 |
-
"timeframe": "1 ساعة"
|
|
|
|
|
|
|
|
|
|
| 303 |
},
|
| 304 |
{
|
| 305 |
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=60&exchange=OANDA",
|
| 306 |
-
"timeframe": "1 ساعة"
|
|
|
|
|
|
|
|
|
|
| 307 |
}
|
| 308 |
]
|
|
|
|
| 309 |
chart_images = []
|
| 310 |
try:
|
| 311 |
-
log(step, "Capturing chart screenshots
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
except Exception as e:
|
| 326 |
log(step, f"Screenshot exception: {e}")
|
| 327 |
|
|
|
|
| 286 |
log(step, f"Twitter fetch error: {te}")
|
| 287 |
twitter_summary = ""
|
| 288 |
|
| 289 |
+
# 2c) Capture chart screenshots:
|
| 290 |
+
# We have two timeframes (15m and 60m), each duplicated twice.
|
| 291 |
+
# First of each timeframe: w=0, h=0, full_page=True
|
| 292 |
+
# Second of each timeframe: w=1920, h=1080, full_page=False
|
| 293 |
+
|
| 294 |
charts = [
|
| 295 |
{
|
| 296 |
+
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=15&exchange=OANDA",
|
| 297 |
+
"timeframe": "15 دقيقة",
|
| 298 |
+
"width": 0,
|
| 299 |
+
"height": 0,
|
| 300 |
+
"full_page": True
|
| 301 |
},
|
|
|
|
| 302 |
{
|
| 303 |
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=15&exchange=OANDA",
|
| 304 |
+
"timeframe": "15 دقيقة",
|
| 305 |
+
"width": 1920,
|
| 306 |
+
"height": 1080,
|
| 307 |
+
"full_page": False
|
| 308 |
},
|
| 309 |
{
|
| 310 |
+
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=60&exchange=OANDA",
|
| 311 |
+
"timeframe": "1 ساعة",
|
| 312 |
+
"width": 0,
|
| 313 |
+
"height": 0,
|
| 314 |
+
"full_page": True
|
| 315 |
},
|
| 316 |
{
|
| 317 |
"url": "https://corvo-ai-charts.static.hf.space/index.html?symbol=XAUUSD&interval=60&exchange=OANDA",
|
| 318 |
+
"timeframe": "1 ساعة",
|
| 319 |
+
"width": 1920,
|
| 320 |
+
"height": 1080,
|
| 321 |
+
"full_page": False
|
| 322 |
}
|
| 323 |
]
|
| 324 |
+
|
| 325 |
chart_images = []
|
| 326 |
try:
|
| 327 |
+
log(step, "Capturing chart screenshots with specific per-item dimensions")
|
| 328 |
+
# Group charts by their requested settings to minimize API calls if multiple share same config.
|
| 329 |
+
# But since each has its own possibly different settings, we’ll call API per chart to be explicit.
|
| 330 |
+
for c in charts:
|
| 331 |
+
log(step, f"Capturing: tf={c['timeframe']} url={c['url']} w={c['width']} h={c['height']} fullPage={c['full_page']}")
|
| 332 |
+
capture_result = capture_screenshots(
|
| 333 |
+
[c["url"]],
|
| 334 |
+
width=c["width"],
|
| 335 |
+
height=c["height"],
|
| 336 |
+
full_page=c["full_page"]
|
| 337 |
+
)
|
| 338 |
+
if capture_result.get("success"):
|
| 339 |
+
for img in capture_result.get("images", []):
|
| 340 |
+
chart_images.append({
|
| 341 |
+
"timeframe": c["timeframe"],
|
| 342 |
+
"imageUrl": img.get("imageUrl")
|
| 343 |
+
})
|
| 344 |
+
else:
|
| 345 |
+
errs = capture_result.get("errors")
|
| 346 |
+
log(step, f"Screenshot capture failed for {c['url']}. Errors: {errs}")
|
| 347 |
+
log(step, f"Prepared {len(chart_images)} chart image entries for chat")
|
| 348 |
except Exception as e:
|
| 349 |
log(step, f"Screenshot exception: {e}")
|
| 350 |
|