diff --git a/gallery/painting/gismeteo/api.py b/gallery/painting/gismeteo/api.py index d9b19ad..6425a48 100644 --- a/gallery/painting/gismeteo/api.py +++ b/gallery/painting/gismeteo/api.py @@ -4,6 +4,7 @@ import logging from typing import Any from bs4 import BeautifulSoup +from fastapi import HTTPException, status from gallery.sketch.source import ApiSource from gallery.sketch.weather.api import WeatherApi @@ -99,6 +100,11 @@ class GismeteoApi(WeatherApi): return result async def get_day(self, location_id: str, date: datetime.date) -> WeatherResponse: + max_date = datetime.date.today() + datetime.timedelta(days=9) + if date > max_date: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, detail={"max_date": max_date.strftime("%Y-%m-%d")} + ) data = await self.SOURCE.request(f"weather-{location_id}/{datehelp.dump(date)}") return self._parse_oneday(date, data)