fix renamer.py

This commit is contained in:
EstrellaXD
2022-06-03 23:51:28 +08:00
parent 65550fc2e1
commit 0137b71e5b
3 changed files with 12 additions and 13 deletions

View File

@@ -75,7 +75,7 @@ class ParserLV2:
if match_obj is not None:
return match_obj.group(2)
for name in split:
if re.search("[\x00-\xff]{4}", name.strip()) is not None:
if re.search("[\u4e00-\u9fa5]", name.strip()) is None:
return name
return split[0]

View File

@@ -12,8 +12,8 @@ DEFAULT_SETTINGS = {
"download_path": "/downloads/Bangumi",
"method": "pn",
"enable_group_tag": True,
"info_path": "config/bangumi.json",
"rule_path": "config/rule.json",
"info_path": "/config/bangumi.json",
"rule_path": "/config/rule.json",
"not_contain": "720",
"get_rule_debug": False,
"rule_url": "https://raw.githubusercontent.com/EstrellaXD/Bangumi_Auto_Collector/main/AutoBangumi/config/rule.json",

View File

@@ -6,21 +6,20 @@ from conf import settings
logger = logging.getLogger(__name__)
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)? (.*)",
]
class Renamer:
def __init__(self, downloadClient: DownloadClient):
self.client = downloadClient
self.rules = [re.compile(rule) for rule in rules]
self.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 rename_normal(self, name):
for rule in self.rules: