From 6e5ade943b4b2c94ee0ce4447040851e5a0eaa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A7=E4=BE=A0?= Date: Wed, 21 Jan 2026 12:40:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=9F=A5=E7=9C=8B=E6=96=87=E4=BB=B6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TMDB图片路径参数增加空值检查 --- app/core/config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/core/config.py b/app/core/config.py index a8c22b2b..9611ddbf 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -851,14 +851,18 @@ class Settings(BaseSettings, ConfigModel, LogConfigModel): rename_format = re.sub(r'/+', '/', rename_format) return rename_format.strip("/") - def TMDB_IMAGE_URL(self, file_path: str, file_size: str = "original") -> str: + def TMDB_IMAGE_URL( + self, file_path: Optional[str], file_size: str = "original" + ) -> Optional[str]: """ 获取TMDB图片网址 :param file_path: TMDB API返回的xxx_path :param file_size: 图片大小,例如:'original', 'w500' 等 - :return: 图片的完整URL + :return: 图片的完整URL,如果 file_path 为空则返回 None """ + if not file_path: + return None return ( f"https://{self.TMDB_IMAGE_DOMAIN}/t/p/{file_size}/{file_path.removeprefix('/')}" )