diff --git a/.env.example b/.env.example index 7715368..82b575b 100644 --- a/.env.example +++ b/.env.example @@ -44,3 +44,4 @@ ENABLE_OSU_AP=false # 启用 osu!AP 统计数据 ENABLE_ALL_MODS_PP=false # 启用所有 Mod 的 PP 计算 ENABLE_SUPPORTER_FOR_ALL_USERS=false # 启用所有新注册用户的支持者状态 ENABLE_ALL_BEATMAP_LEADERBOARD=false # 启用所有谱面的排行榜(没有排行榜的谱面会以 APPROVED 状态返回) +SEASONAL_BACKGROUNDS='[]' # 季节背景图 URL 列表 diff --git a/README.md b/README.md index bcdd149..01ea6d9 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ Fetcher 用于从 osu! 官方 API 获取数据,使用 osu! 官方 API 的 OAut | `ENABLE_ALL_MODS_PP` | 启用所有 Mod 的 PP 计算 | `false` | | `ENABLE_SUPPORTER_FOR_ALL_USERS` | 启用所有新注册用户的支持者状态 | `false` | | `ENABLE_ALL_BEATMAP_LEADERBOARD` | 启用所有谱面的排行榜 | `false` | +| `SEASONAL_BACKGROUNDS` | 季节背景图 URL 列表 | `[]` | > **注意**: 在生产环境中,请务必更改默认的密钥和密码! diff --git a/app/config.py b/app/config.py index f0df438..a5045e3 100644 --- a/app/config.py +++ b/app/config.py @@ -55,6 +55,7 @@ class Settings(BaseSettings): enable_all_mods_pp: bool = False enable_supporter_for_all_users: bool = False enable_all_beatmap_leaderboard: bool = False + seasonal_backgrounds: list[str] = [] @field_validator("fetcher_scopes", mode="before") def validate_fetcher_scopes(cls, v: Any) -> list[str]: diff --git a/app/router/__init__.py b/app/router/__init__.py index 22f6c70..bc82905 100644 --- a/app/router/__init__.py +++ b/app/router/__init__.py @@ -6,6 +6,7 @@ from . import ( # pyright: ignore[reportUnusedImport] # noqa: F401 beatmap, beatmapset, me, + misc, relationship, room, score, diff --git a/app/router/misc.py b/app/router/misc.py new file mode 100644 index 0000000..1921008 --- /dev/null +++ b/app/router/misc.py @@ -0,0 +1,25 @@ +from __future__ import annotations + +from datetime import UTC, datetime + +from app.config import settings + +from .api_router import router + +from pydantic import BaseModel + + +class Background(BaseModel): + url: str + + +class BackgroundsResp(BaseModel): + ends_at: datetime = datetime(year=9999, month=12, day=31, tzinfo=UTC) + backgrounds: list[Background] + + +@router.get("/seasonal-backgrounds", response_model=BackgroundsResp) +async def get_seasonal_backgrounds(): + return BackgroundsResp( + backgrounds=[Background(url=url) for url in settings.seasonal_backgrounds] + )