From 89edbb93f55cd95772524b5f13231ff5762bdbca Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sun, 17 Nov 2024 08:52:15 +0800 Subject: [PATCH] fix #3135 --- app/chain/media.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/app/chain/media.py b/app/chain/media.py index 33d62d34..3b0d265a 100644 --- a/app/chain/media.py +++ b/app/chain/media.py @@ -377,6 +377,11 @@ class MediaChain(ChainBase, metaclass=Singleton): if mediainfo.type == MediaType.MOVIE: # 电影 if fileitem.type == "file": + # 是否已存在 + nfo_path = filepath.with_suffix(".nfo") + if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): + logger.debug(f"已存在nfo文件:{nfo_path}") + return # 电影文件 logger.info(f"正在生成电影nfo:{mediainfo.title_year} - {filepath.name}") movie_nfo = self.metadata_nfo(meta=meta, mediainfo=mediainfo) @@ -384,10 +389,6 @@ class MediaChain(ChainBase, metaclass=Singleton): logger.warn(f"{filepath.name} nfo文件生成失败!") return # 保存或上传nfo文件到上级目录 - nfo_path = filepath.with_suffix(".nfo") - if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): - logger.info(f"已存在nfo文件:{nfo_path}") - return __save_file(_fileitem=parent, _path=nfo_path, _content=movie_nfo) else: # 电影目录 @@ -419,7 +420,12 @@ class MediaChain(ChainBase, metaclass=Singleton): else: # 电视剧 if fileitem.type == "file": - # 当前为集文件,重新识别季集 + # 是否已存在 + nfo_path = filepath.with_suffix(".nfo") + if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): + logger.debug(f"已存在nfo文件:{nfo_path}") + return + # 重新识别季集 file_meta = MetaInfoPath(filepath) if not file_meta.begin_episode: logger.warn(f"{filepath.name} 无法识别文件集数!") @@ -435,10 +441,6 @@ class MediaChain(ChainBase, metaclass=Singleton): logger.warn(f"{filepath.name} nfo生成失败!") return # 保存或上传nfo文件到上级目录 - nfo_path = filepath.with_suffix(".nfo") - if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): - logger.info(f"已存在nfo文件:{nfo_path}") - return __save_file(_fileitem=parent, _path=nfo_path, _content=episode_nfo) # 获取集的图片 image_dict = self.metadata_img(mediainfo=file_mediainfo, @@ -468,16 +470,17 @@ class MediaChain(ChainBase, metaclass=Singleton): # 识别文件夹名称 season_meta = MetaInfo(filepath.name) if season_meta.begin_season: + # 是否已存在 + nfo_path = filepath / "season.nfo" + if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): + logger.debug(f"已存在nfo文件:{nfo_path}") + return # 当前目录有季号,生成季nfo season_nfo = self.metadata_nfo(meta=meta, mediainfo=mediainfo, season=season_meta.begin_season) if not season_nfo: logger.warn(f"无法生成电视剧季nfo文件:{meta.name}") return # 写入nfo到根目录 - nfo_path = filepath / "season.nfo" - if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): - logger.info(f"已存在nfo文件:{nfo_path}") - return __save_file(_fileitem=fileitem, _path=nfo_path, _content=season_nfo) # TMDB季poster图片 image_dict = self.metadata_img(mediainfo=mediainfo, season=season_meta.begin_season) @@ -495,16 +498,17 @@ class MediaChain(ChainBase, metaclass=Singleton): __save_file(_fileitem=fileitem, _path=image_path, _content=content) # 判断当前目录是不是剧集根目录 if season_meta.name: + # 是否已存在 + nfo_path = filepath / "tvshow.nfo" + if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): + logger.debug(f"已存在nfo文件:{nfo_path}") + return # 当前目录有名称,生成tvshow nfo 和 tv图片 tv_nfo = self.metadata_nfo(meta=meta, mediainfo=mediainfo) if not tv_nfo: logger.warn(f"无法生成电视剧nfo文件:{meta.name}") return # 写入tvshow nfo到根目录 - nfo_path = filepath / "tvshow.nfo" - if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, path=nfo_path): - logger.info(f"已存在nfo文件:{nfo_path}") - return __save_file(_fileitem=fileitem, _path=nfo_path, _content=tv_nfo) # 生成目录图片 image_dict = self.metadata_img(mediainfo=mediainfo)