Skip to content

Commit

Permalink
🎨 增加识别准确度
Browse files Browse the repository at this point in the history
  • Loading branch information
KimigaiiWuyi committed Jul 25, 2024
1 parent 400cdc2 commit ce4b9f6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

output
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.languageServer": "None"
}
24 changes: 21 additions & 3 deletions src/Bangumi_Auto_Rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@
UNDERLINE = "\033[4m"


def match_and_extract(input_string: str):
pattern = re.compile(r'S(\d+)E(\d+)')
match = pattern.search(input_string)

if match:
season = int(match.group(1))
episode = int(match.group(2))
return season, episode
else:
return None


def chinese_to_arabic(cn: str) -> int:
unit = 0
ldig = []
Expand Down Expand Up @@ -281,23 +293,29 @@ def process_sub(
break
else:
for ex in EXTRA_TAG:
if ex.lower() in item_name_r:
if f'[{ex.lower()}]' in item_name_r:
t = work_path / 'extra'
R[item_path] = t / item_name
break
else:
for s0 in S0_TAG:
if s0.lower() in item_name_r:
if f'[{s0.lower()}]' in item_name_r:
t = work_path / 'Season0'
R[item_path] = t / item_name
break
else:
t = work_path / f'Season{season_id}'
epp = extract_base_num(item_name)
if epp is None:
ep = int(extract_number(item_name))
else:
ep = int(epp)

_idata = match_and_extract(item_name)
if _idata:
season_id, ep = _idata[0], _idata[1]

t = work_path / f'Season{season_id}'

ep = f'0{ep}' if ep < 10 else ep
s = f'0{int(season_id)}'
ss = s if season_id < 10 else int(season_id)
Expand Down

0 comments on commit ce4b9f6

Please sign in to comment.