diff --git a/app/modules/fanart/__init__.py b/app/modules/fanart/__init__.py index aaf8a8c2..82ec87db 100644 --- a/app/modules/fanart/__init__.py +++ b/app/modules/fanart/__init__.py @@ -333,7 +333,7 @@ class FanartModule(_ModuleBase): if not result or result.get('status') == 'error': logger.warn(f"没有获取到 {mediainfo.title_year} 的Fanart图片数据") return - # FIXME 季图片要区分季号 + # 获取所有图片 for name, images in result.items(): if not images: continue @@ -341,10 +341,17 @@ class FanartModule(_ModuleBase): continue # 按欢迎程度倒排 images.sort(key=lambda x: int(x.get('likes', 0)), reverse=True) + # 取第一张图片 + image_obj = images[0] # 图片属性xx_path image_name = self.__name(name) + image_season = image_obj.get('season') + # 设置图片 + if image_name.startswith("season") and image_season: + # 季图片格式 seasonxx-poster + image_name = f"season{str(image_season).rjust(2, '0')}-{image_name[6:]}" if not mediainfo.get_image(image_name): - mediainfo.set_image(image_name, images[0].get('url')) + mediainfo.set_image(image_name, image_obj.get('url')) return mediainfo diff --git a/app/modules/themoviedb/scraper.py b/app/modules/themoviedb/scraper.py index f4e27567..04db3ccb 100644 --- a/app/modules/themoviedb/scraper.py +++ b/app/modules/themoviedb/scraper.py @@ -37,7 +37,7 @@ class TmdbScraper: return {} try: - # 电影 + # 电影,路径为文件名 名称/名称.xxx 或者蓝光原盘目录 名称/名称 if mediainfo.type == MediaType.MOVIE: # 不已存在时才处理 if not file_path.with_name("movie.nfo").exists() \ @@ -91,20 +91,17 @@ class TmdbScraper: # URL url = f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original{seasoninfo.get('poster_path')}" self.__save_image(url, file_path.parent.with_name(f"season{sea_seq}-poster{ext}")) - # FIXME 季的其它图片 + # 季的其它图片 for attr_name, attr_value in vars(mediainfo).items(): if attr_value \ and attr_name.startswith("season") \ - and not attr_name.endswith("poster") \ + and not attr_name.endswith("poster_path") \ and attr_value \ and isinstance(attr_value, str) \ and attr_value.startswith("http"): - image_name = attr_name.replace("_path", - "").replace("season", - f"{sea_seq}-") \ - + Path(attr_value).suffix + image_name = attr_name.replace("_path", "") + Path(attr_value).suffix self.__save_image(url=attr_value, - file_path=file_path.parent.with_name(f"season{image_name}")) + file_path=file_path.parent.with_name(image_name)) # 查询集详情 episodeinfo = __get_episode_detail(seasoninfo, meta.begin_episode) if episodeinfo: