From d4ac585549071c71508cc09eaf94d2ee8a18e5da Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 22 Oct 2024 10:42:09 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E5=AD=A3=E5=88=AE?= =?UTF-8?q?=E5=89=8A=E5=9B=BE=E7=89=87=E9=94=99=E4=BD=8D=20&&=20=E9=9B=86?= =?UTF-8?q?=E5=88=AE=E5=89=8A=E5=9B=BE=E7=89=87None?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/media.py | 10 +++++++--- app/modules/themoviedb/scraper.py | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/chain/media.py b/app/chain/media.py index afb8542a..8be6a714 100644 --- a/app/chain/media.py +++ b/app/chain/media.py @@ -338,6 +338,7 @@ class MediaChain(ChainBase, metaclass=Singleton): tmp_file = settings.TEMP_PATH / _path.name tmp_file.write_bytes(_content) logger.info(f"保存文件:【{_fileitem.storage}】{_path}") + _fileitem.path = str(_path.parent) self.storagechain.upload_file(fileitem=_fileitem, path=tmp_file) if tmp_file.exists(): tmp_file.unlink() @@ -402,7 +403,8 @@ class MediaChain(ChainBase, metaclass=Singleton): and attr_value.startswith("http"): image_name = attr_name.replace("_path", "") + Path(attr_value).suffix image_path = filepath / image_name - if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=image_path): + if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, + path=image_path): logger.info(f"已存在图片文件:{image_path}") continue # 下载图片 @@ -476,7 +478,8 @@ class MediaChain(ChainBase, metaclass=Singleton): if image_dict: for image_name, image_url in image_dict.items(): image_path = filepath.with_name(image_name) - if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=image_path): + if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, + path=image_path): logger.info(f"已存在图片文件:{image_path}") continue # 下载图片 @@ -500,7 +503,8 @@ class MediaChain(ChainBase, metaclass=Singleton): if image_dict: for image_name, image_url in image_dict.items(): image_path = filepath / image_name - if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=image_path): + if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, + path=image_path): logger.info(f"已存在图片文件:{image_path}") continue # 下载图片 diff --git a/app/modules/themoviedb/scraper.py b/app/modules/themoviedb/scraper.py index e58426d5..27235aff 100644 --- a/app/modules/themoviedb/scraper.py +++ b/app/modules/themoviedb/scraper.py @@ -58,19 +58,19 @@ class TmdbScraper: """ images = {} if season: - # 只需要季的图片 + # 只需要集的图片 if episode: - # 季的图片 + # 集的图片 seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, season) if seasoninfo: episodeinfo = self.__get_episode_detail(seasoninfo, episode) - if episodeinfo: + if episodeinfo and episodeinfo.get("still_path"): # TMDB集still图片 still_name = f"{episode}" still_url = f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original{episodeinfo.get('still_path')}" images[still_name] = still_url else: - # 集的图片 + # 季的图片 seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, season) if seasoninfo: # TMDB季poster图片