Skip to content

Commit

Permalink
格式化ep, 兼容 .5 格式
Browse files Browse the repository at this point in the history
  • Loading branch information
Nriver committed Jan 8, 2024
1 parent 9c245a0 commit 8e1ce9b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions EpisodeReName.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def get_season_and_ep(file_path):
if force_rename:
season, ep = res[1], res[2]
season = str(int(season)).zfill(2)
ep = str(int(ep)).zfill(2)
ep = ep_format(ep)
return season, ep
else:
return None, None
Expand All @@ -409,14 +409,14 @@ def get_season_and_ep(file_path):
if res:
season, ep = res[0][0], res[0][1]
season = str(int(season)).zfill(2)
ep = str(int(ep)).zfill(2)
ep = ep_format(ep)
return season, ep
pat = '[Ss](\d{1,4})[Ee][Pp](\d{1,4}(\.5)?)'
res = re.findall(pat, file_name.upper())
if res:
season, ep = res[0][0], res[0][1]
season = str(int(season)).zfill(2)
ep = str(int(ep)).zfill(2)
ep = ep_format(ep)
return season, ep

season = get_season_cascaded(parent_folder_path)
Expand All @@ -440,7 +440,7 @@ def get_season_and_ep(file_path):
logger.info(f"{'根据特殊规则找到了集数'}")
ep = res[0]
season = str(int(season)).zfill(2)
ep = str(int(ep)).zfill(2)
ep = ep_format(ep)
return season, ep
except Exception as e:
logger.info(f'{e}')
Expand Down Expand Up @@ -622,6 +622,16 @@ def get_season_path(file_path):
return season_path


def ep_format(ep):
# 格式化ep, 兼容 .5 格式
if '.' in ep:
ep_int, ep_tail = ep.split('.', 1)
ep = str(int(ep_int)).zfill(2) + '.' + ep_tail
else:
ep = str(int(ep)).zfill(2)
return ep


def ep_offset_patch(file_path, ep):
# 多季集数修正
# 20220721 修改集数修正修正规则:可以用 + - 符号标记修正数值, 表达更直观
Expand Down

0 comments on commit 8e1ce9b

Please sign in to comment.