- 为了一些奇怪的字幕组做了一些微小的调整
This commit is contained in:
EstrellaXD
2022-07-17 10:31:32 +08:00
parent 2d03f73b9c
commit 227d62c278
4 changed files with 19 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
DEFAULT_SETTINGS = {
"version": "2.5.13",
"version": "2.5.14",
"data_version": 4.0,
"host_ip": "localhost:8080",
"sleep_time": 7200,

View File

@@ -41,7 +41,7 @@ class APIProcess:
def remove_rule(name):
datas = json_config.load(settings.info_path)["bangumi_info"]
for data in datas:
if re.search(name.lower(), data["title_raw"].lower()) is not None:
if re.search(name.lower(), data["title_raw"].lower()):
datas.remove(data)
json_config.save(settings.info_path, datas)
return "Success"

View File

@@ -30,9 +30,9 @@ CHINESE_NUMBER_MAP = {
@dataclass
class Episode:
title_en: str
title_zh: str
title_jp: str
title_en: str or None
title_zh: str or None
title_jp: str or None
season: int
season_raw: str
episode: int
@@ -79,7 +79,7 @@ class RawParser:
@staticmethod
def name_process(name: str):
name_en, name_zh, name_jp = "", "", ""
name_en, name_zh, name_jp = None, None, None
name = name.strip()
split = re.split("/|\s{2}|-\s{2}", name.replace("(仅限港澳台地区)", ""))
while "" in split:
@@ -96,11 +96,11 @@ class RawParser:
split = [item.strip(), " ".join(split_space[idx+1:]).strip()]
break
for item in split:
if re.search(r"[\u0800-\u4e00]{2,}", item):
if re.search(r"[\u0800-\u4e00]{2,}", item) and not name_jp:
name_jp = item.strip()
elif re.search(r"[\u4e00-\u9fa5]{2,}", item):
elif re.search(r"[\u4e00-\u9fa5]{2,}", item) and not name_zh:
name_zh = item.strip()
elif re.search(r"[a-zA-Z]{3,}", item):
elif re.search(r"[a-zA-Z]{3,}", item) and not name_en:
name_en = item.strip()
return name_en, name_zh, name_jp
@@ -122,7 +122,6 @@ class RawParser:
def clean_sub(sub: str | None) -> str | None:
if sub is None:
return sub
# TODO: 这里需要改成更精准的匹配,可能不止 _MP4 ?
return re.sub(r"_MP4|_MKV", "", sub)
def process(self, raw_title: str):
@@ -163,5 +162,5 @@ class RawParser:
if __name__ == "__main__":
test = RawParser()
test_txt = "[SWSUB][7月新番][继母的拖油瓶是我的前女友 / 継母の连れ子が元カノだった][001][GB_JP][AVC][1080P][网盘][无修正] [331.6MB] [复制磁连]"
en, zh, jp = test.name_process("继母的拖油瓶是我的前女友 / 継母の连れ子が元カノだった")
print(f"en:{en}, zh:{zh}, jp:{jp}")
ep = test.analyse(test_txt)
print(f"en:{ep.title_en}, zh:{ep.title_zh}, jp:{ep.title_jp}")

View File

@@ -19,6 +19,7 @@ class TitleParser:
return self._download_parser.download_rename(download_raw, folder_name, season, suffix, method)
def tmdb_parser(self, title: str, season: int):
official_title, tmdb_season = None, None
try:
tmdb_info = self._tmdb_parser.tmdb_search(title)
logger.debug(f"TMDB Matched, title is {tmdb_info.title_zh}")
@@ -29,14 +30,15 @@ class TitleParser:
official_title = f"{tmdb_info.title_zh} ({tmdb_info.year_number})"
elif settings.title_language == "jp":
official_title = f"{tmdb_info.title_jp} ({tmdb_info.year_number})"
season = tmdb_info.last_season
return official_title, season
tmdb_season = tmdb_info.last_season if tmdb_info.last_season else season
official_title = official_title if official_title else title
return official_title, tmdb_season
def return_dict(self, raw: str):
try:
episode = self.raw_parser(raw)
title_search = episode.title_zh if episode.title_zh != "" else episode.title_en
title_raw = episode.title_en if episode.title_en != "" else episode.title_zh
title_search = episode.title_zh if episode.title_zh else episode.title_en
title_raw = episode.title_en if episode.title_en else episode.title_zh
if settings.enable_tmdb:
official_title, season = self.tmdb_parser(title_search, episode.season)
else:
@@ -45,7 +47,7 @@ class TitleParser:
data = {
"official_title": official_title,
"title_raw": title_raw,
"season": season if season is not None else episode.season,
"season": season,
"season_raw": episode.season_raw,
"group": episode.group,
"dpi": episode.resolution,
@@ -65,7 +67,7 @@ if __name__ == '__main__':
from conf.const_dev import DEV_SETTINGS
settings.init(DEV_SETTINGS)
T = TitleParser()
raw = "[Lilith-Raws] 在地下城寻求邂逅是否搞错了什么/Danmachi [无修正][01][Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]"
raw = "[Lilith-Raws] 在地下城寻求邂逅是否搞错了什么/Danmachi S4[01][Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]"
season = int(re.search(r"\d{1,2}", "S02").group())
dict = T.return_dict(raw)
print(dict)