Skip to content

Commit 51dd7f5

Browse files
authored
Merge pull request jxxghp#5512 from cddjr/bugfix/issue-5501
2 parents af7e1e7 + ea5d855 commit 51dd7f5

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

app/chain/media.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def __list_files(_fileitem: schemas.FileItem):
435435
"""
436436
列出下级文件
437437
"""
438-
return storagechain.list_files(fileitem=_fileitem)
438+
return storagechain.list_files(fileitem=_fileitem) or []
439439

440440
def __save_file(_fileitem: schemas.FileItem, _path: Path, _content: Union[bytes, str]):
441441
"""
@@ -668,7 +668,7 @@ def __download_and_save_image(_fileitem: schemas.FileItem, _path: Path, _url: st
668668
if (
669669
file.type == "dir"
670670
and file.name not in settings.RENAME_FORMAT_S0_NAMES
671-
and not file.name.lower().startswith("season")
671+
and MetaInfo(file.name).begin_season is None
672672
):
673673
# 电视剧不处理非季子目录
674674
continue
@@ -689,9 +689,13 @@ def __download_and_save_image(_fileitem: schemas.FileItem, _path: Path, _url: st
689689
if filepath.name in settings.RENAME_FORMAT_S0_NAMES:
690690
season_meta.begin_season = 0
691691
elif season_meta.name and season_meta.begin_season is not None:
692-
# 当前目录含有非季目录的名称,但却有季信息(通常是被辅助识别词指定了)
693-
# 这种情况应该是剧集根目录,不能按季目录刮削,否则会导致`season_poster`的路径错误 详见issue#5373
694-
season_meta.begin_season = None
692+
# 目录含剧名且包含季号,需排除辅助词重新识别元数据,避免误判根目录 (issue 5501)
693+
season_meta_no_custom = MetaInfo(
694+
filepath.name, custom_words=["#"]
695+
)
696+
if season_meta_no_custom.begin_season is None:
697+
# 季号是由辅助词指定的,按剧集根目录处理,避免`season_poster`路径错误 (issue 5373)
698+
season_meta.begin_season = None
695699
if season_meta.begin_season is not None:
696700
# 检查季NFO开关
697701
if scraping_switchs.get('season_nfo', True):
@@ -812,6 +816,8 @@ def __download_and_save_image(_fileitem: schemas.FileItem, _path: Path, _url: st
812816
logger.info(f"已存在图片文件:{image_path}")
813817
else:
814818
logger.info(f"电视剧图片刮削已关闭,跳过:{image_name}")
819+
else:
820+
logger.warn("无法识别元数据,跳过")
815821
logger.info(f"{filepath.name} 刮削完成")
816822

817823
async def async_recognize_by_meta(self, metainfo: MetaBase,

app/helper/directory.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ def get_media_root_path(rename_format: str, rename_path: Path) -> Optional[Path]
151151
if not matchs:
152152
continue
153153
# 处理特例,有的人重命名的第一层是年份、分辨率
154-
if any("title" in m for m in matchs):
155-
# 找出最后一层含有标题参数的目录作为媒体根目录
154+
if (any("title" in m for m in matchs)
155+
and not any("season" in m for m in matchs)):
156+
# 找出最后一层含有标题且不含季参数的目录作为媒体根目录
156157
rename_format_level = level
157158
break
158159
else:

0 commit comments

Comments
 (0)