去掉了字幕组信息

This commit is contained in:
EstrellaXD
2022-05-15 15:29:04 +08:00
parent 7d58704251
commit 7be34940e0
2 changed files with 31 additions and 4 deletions

26
test.py Normal file
View File

@@ -0,0 +1,26 @@
import re
import os
file_name = '[Sakurato] Machikado Mazoku 2-choume [06][AVC-8bit 1080P AAC][CHS]'
episode_rules = [r'(.*)\[(\d{1,3}|\d{1,3}\.\d{1,2})(?:v\d{1,2})?(?:END)?\](.*)',
r'(.*)\[E(\d{1,3}|\d{1,3}\.\d{1,2})(?:v\d{1,2})?(?:END)?\](.*)',
r'(.*)\[第(\d*\.*\d*)话(?:END)?\](.*)',
r'(.*)\[第(\d*\.*\d*)話(?:END)?\](.*)',
r'(.*)第(\d*\.*\d*)话(?:END)?(.*)',
r'(.*)第(\d*\.*\d*)話(?:END)?(.*)',
r'(.*)- (\d{1,3}|\d{1,3}\.\d{1,2})(?:v\d{1,2})?(?:END)? (.*)']
def new_name(name):
n = re.split(r'\[|\]', name)
file_name = name.replace(f'[{n[1]}]', '')
for rule in episode_rules:
matchObj = re.match(rule, file_name, re.I)
if matchObj is not None:
new_name = f'{matchObj.group(1)}E{matchObj.group(2)} {matchObj.group(3)}'
return new_name
print(new_name(file_name))