From 7ed26fadb6d7e245f41194657cae65d7b0194e5d Mon Sep 17 00:00:00 2001 From: LM Date: Tue, 10 Jun 2025 17:25:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0fanart=E5=88=AE?= =?UTF-8?q?=E5=89=8A=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=85=88=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E4=B8=AD=E6=96=87=E3=80=81=E8=8B=B1=E6=96=87=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/fanart/__init__.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/modules/fanart/__init__.py b/app/modules/fanart/__init__.py index 4957b760..1a229fcf 100644 --- a/app/modules/fanart/__init__.py +++ b/app/modules/fanart/__init__.py @@ -399,10 +399,22 @@ class FanartModule(_ModuleBase): if not mediainfo.get_image(season_image): mediainfo.set_image(season_image, image_obj.get('url')) else: - # 其他图片,按欢迎程度倒排 - images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) - # 取第一张图片 - image_obj = images[0] + # 其他图片,优先zh、再en、最后like最多 + def pick_best_image(images): + # 先找zh + zh_images = [img for img in images if img.get('lang') == 'zh'] + if zh_images: + zh_images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) + return zh_images[0] + # 再找en + en_images = [img for img in images if img.get('lang') == 'en'] + if en_images: + en_images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) + return en_images[0] + # 都没有就like最多的 + images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) + return images[0] + image_obj = pick_best_image(images) # 设置图片,没有图片才设置 if not mediainfo.get_image(image_name): mediainfo.set_image(image_name, image_obj.get('url')) From 880272f96eea7398fc42a0a82b5780ebbda69bcd Mon Sep 17 00:00:00 2001 From: LM Date: Tue, 10 Jun 2025 17:59:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?update:=20=E4=BC=98=E5=8C=96fanart=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/fanart/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/modules/fanart/__init__.py b/app/modules/fanart/__init__.py index 1a229fcf..5f180429 100644 --- a/app/modules/fanart/__init__.py +++ b/app/modules/fanart/__init__.py @@ -399,19 +399,25 @@ class FanartModule(_ModuleBase): if not mediainfo.get_image(season_image): mediainfo.set_image(season_image, image_obj.get('url')) else: - # 其他图片,优先zh、再en、最后like最多 + # 其他图片,优先环境变量指定语言,再like最多 def pick_best_image(images): - # 先找zh + lang_env = settings.FANART_LANG + if lang_env: + langs = [lang.strip() for lang in lang_env.split(",") if lang.strip()] + for lang in langs: + lang_images = [img for img in images if img.get('lang') == lang] + if lang_images: + lang_images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) + return lang_images[0] + # 没设置或没找到,按原逻辑 zh、en、like最多 zh_images = [img for img in images if img.get('lang') == 'zh'] if zh_images: zh_images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) return zh_images[0] - # 再找en en_images = [img for img in images if img.get('lang') == 'en'] if en_images: en_images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) return en_images[0] - # 都没有就like最多的 images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) return images[0] image_obj = pick_best_image(images) From 95b7ba28e4f3008571fac0fb7024bc96ca44e246 Mon Sep 17 00:00:00 2001 From: LM Date: Tue, 10 Jun 2025 17:59:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0fanart=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/core/config.py b/app/core/config.py index 9bfab0f2..ea4c2ae2 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -114,6 +114,8 @@ class ConfigModel(BaseModel): TVDB_V4_API_PIN: str = "" # Fanart开关 FANART_ENABLE: bool = True + # Fanart语言 + FANART_LANG: str = "zh,en" # Fanart API Key FANART_API_KEY: str = "d2d31f9ecabea050fc7d68aa3146015f" # 115 AppId