Handle empty MGM daily forecasts without 403 fallback
This commit is contained in:
@@ -76,10 +76,13 @@ class MgmSourceMixin:
|
|||||||
or "Ankara Bölge",
|
or "Ankara Bölge",
|
||||||
}
|
}
|
||||||
|
|
||||||
# 2. 每日预报(尝试两个可能的 API 路径)
|
# 2. 每日预报
|
||||||
|
# 2026-03: /api/tahminler/gunluk now returns 403 consistently, while
|
||||||
|
# /web/tahminler/gunluk is reachable but may legitimately return [] for
|
||||||
|
# station-level forecast. Keep the reachable endpoint only and fall
|
||||||
|
# back to hourly/current data when station forecast is unavailable.
|
||||||
forecast_urls = [
|
forecast_urls = [
|
||||||
f"{base_url}/tahminler/gunluk?istno={istno}",
|
f"{base_url}/tahminler/gunluk?istno={istno}",
|
||||||
f"https://servis.mgm.gov.tr/api/tahminler/gunluk?istno={istno}",
|
|
||||||
]
|
]
|
||||||
for forecast_url in forecast_urls:
|
for forecast_url in forecast_urls:
|
||||||
try:
|
try:
|
||||||
@@ -107,6 +110,10 @@ class MgmSourceMixin:
|
|||||||
target_date = (datetime.now() + timedelta(days=i)).strftime("%Y-%m-%d")
|
target_date = (datetime.now() + timedelta(days=i)).strftime("%Y-%m-%d")
|
||||||
results["daily_forecasts"][target_date] = d_high
|
results["daily_forecasts"][target_date] = d_high
|
||||||
break
|
break
|
||||||
|
logger.debug(
|
||||||
|
f"MGM daily forecast unavailable for istno={istno}: "
|
||||||
|
f"{forecast_url} returned empty payload"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"MGM forecast URL {forecast_url} returned {daily_resp.status_code}"
|
f"MGM forecast URL {forecast_url} returned {daily_resp.status_code}"
|
||||||
|
|||||||
Reference in New Issue
Block a user