mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
fix: 修复fanart季图片下载缺失/错误的问题
This commit is contained in:
@@ -552,6 +552,29 @@ class MediaChain(ChainBase, metaclass=Singleton):
|
|||||||
if not parent:
|
if not parent:
|
||||||
parent = self.storagechain.get_parent_item(fileitem)
|
parent = self.storagechain.get_parent_item(fileitem)
|
||||||
__save_file(_fileitem=parent, _path=image_path, _content=content)
|
__save_file(_fileitem=parent, _path=image_path, _content=content)
|
||||||
|
# 额外fanart季图片:poster thumb banner
|
||||||
|
image_dict = self.metadata_img(mediainfo=mediainfo)
|
||||||
|
if image_dict:
|
||||||
|
for image_name, image_url in image_dict.items():
|
||||||
|
if image_name.startswith("season"):
|
||||||
|
image_path = filepath.with_name(image_name)
|
||||||
|
# 只下载当前刮削季的图片
|
||||||
|
image_season = "00" if "specials" in image_name else image_name[6:8]
|
||||||
|
if image_season != str(season_meta.begin_season).rjust(2, '0'):
|
||||||
|
logger.info(f"当前刮削季为:{season_meta.begin_season},跳过文件:{image_path}")
|
||||||
|
continue
|
||||||
|
if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage,
|
||||||
|
path=image_path):
|
||||||
|
logger.info(f"已存在图片文件:{image_path}")
|
||||||
|
continue
|
||||||
|
# 下载图片
|
||||||
|
content = __download_image(image_url)
|
||||||
|
# 保存图片文件到当前目录
|
||||||
|
if content:
|
||||||
|
if not parent:
|
||||||
|
parent = self.storagechain.get_parent_item(fileitem)
|
||||||
|
__save_file(_fileitem=parent, _path=image_path, _content=content)
|
||||||
|
|
||||||
# 判断当前目录是不是剧集根目录
|
# 判断当前目录是不是剧集根目录
|
||||||
if not season_meta.season:
|
if not season_meta.season:
|
||||||
# 是否已存在
|
# 是否已存在
|
||||||
@@ -570,6 +593,9 @@ class MediaChain(ChainBase, metaclass=Singleton):
|
|||||||
image_dict = self.metadata_img(mediainfo=mediainfo)
|
image_dict = self.metadata_img(mediainfo=mediainfo)
|
||||||
if image_dict:
|
if image_dict:
|
||||||
for image_name, image_url in image_dict.items():
|
for image_name, image_url in image_dict.items():
|
||||||
|
# 不下载季图片
|
||||||
|
if image_name.startswith("season"):
|
||||||
|
continue
|
||||||
image_path = filepath / image_name
|
image_path = filepath / image_name
|
||||||
if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage,
|
if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage,
|
||||||
path=image_path):
|
path=image_path):
|
||||||
|
|||||||
@@ -377,20 +377,30 @@ class FanartModule(_ModuleBase):
|
|||||||
continue
|
continue
|
||||||
if not isinstance(images, list):
|
if not isinstance(images, list):
|
||||||
continue
|
continue
|
||||||
# 按欢迎程度倒排
|
|
||||||
images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True)
|
|
||||||
# 取第一张图片
|
|
||||||
image_obj = images[0]
|
|
||||||
# 图片属性xx_path
|
# 图片属性xx_path
|
||||||
image_name = self.__name(name)
|
image_name = self.__name(name)
|
||||||
image_season = image_obj.get('season')
|
if image_name.startswith("season"):
|
||||||
# 设置图片
|
# 季图片,图片格式seasonxx-xxxx/season-specials-xxxx
|
||||||
if image_name.startswith("season") and image_season:
|
for image_obj in images:
|
||||||
# 季图片格式 seasonxx-poster
|
image_season = image_obj.get('season')
|
||||||
image_name = f"season{str(image_season).rjust(2, '0')}-{image_name[6:]}"
|
if image_season is not None:
|
||||||
if not mediainfo.get_image(image_name):
|
# 包括poster,thumb,banner
|
||||||
# 没有图片才设置
|
if image_season == '0':
|
||||||
mediainfo.set_image(image_name, image_obj.get('url'))
|
season_image = f"season-specials-{image_name[6:]}"
|
||||||
|
else:
|
||||||
|
season_image = f"season{str(image_season).rjust(2, '0')}-{image_name[6:]}"
|
||||||
|
# 设置图片,没有图片才设置
|
||||||
|
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]
|
||||||
|
# 设置图片,没有图片才设置
|
||||||
|
if not mediainfo.get_image(image_name):
|
||||||
|
mediainfo.set_image(image_name, image_obj.get('url'))
|
||||||
|
|
||||||
return mediainfo
|
return mediainfo
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user