Fix jysub problem.

Close #231 #137
This commit is contained in:
EstrellaXD
2023-05-05 10:47:49 +08:00
parent 2bcfb88c75
commit 203de7b9e7
3 changed files with 33 additions and 14 deletions

View File

@@ -7,7 +7,7 @@ logger = logging.getLogger(__name__)
EPISODE_RE = re.compile(r"\d+")
TITLE_RE = re.compile(
r"(.*|\[.*])( -? \d+|\[\d+]|\[\d+.?[vV]\d]|[ 第]?\d+[话話集]|\[\d+.?END]|[Ee][Pp]?\d+)(.*)"
r"(.*|\[.*])( -? \d+|\[\d+]|\[\d+.?[vV]\d]|\d+[话話集]|\[第?\d+[话話集]]|\[\d+.?END]|[Ee][Pp]?\d+)(.*)"
)
RESOLUTION_RE = re.compile(r"1080|720|2160|4K")
SOURCE_RE = re.compile(r"B-Global|[Bb]aha|[Bb]ilibili|AT-X|Web")
@@ -41,6 +41,10 @@ def prefix_process(raw: str, group: str) -> str:
raw = re.sub(f".{group}.", "", raw)
raw_process = PREFIX_RE.sub("/", raw)
arg_group = raw_process.split("/")
while "" in arg_group:
arg_group.remove("")
if len(arg_group) == 1:
arg_group = arg_group[0].split(" ")
for arg in arg_group:
if re.search(r"新番|月?番", arg) and len(arg) <= 5:
raw = re.sub(f".{arg}.", "", raw)
@@ -123,6 +127,7 @@ def clean_sub(sub: str | None) -> str | None:
return sub
return re.sub(r"_MP4|_MKV", "", sub)
def process(raw_title: str):
raw_title = raw_title.strip()
content_title = pre_process(raw_title)
@@ -163,5 +168,9 @@ def raw_parser(raw: str) -> Episode | None:
return Episode(name_en, name_zh, name_jp, season, sr, episode, sub, group, dpi, source)
if __name__ == '__main__':
title = "【幻樱字幕组】【4月新番】【古见同学有交流障碍症 第二季 Komi-san wa, Komyushou Desu. S02】【22】【GB_MP4】【1920X1080】"
ep = raw_parser(title)
print(ep)

View File

@@ -46,7 +46,8 @@ def test_raw_parser():
content = "[织梦字幕组][尼尔:机械纪元 NieR Automata Ver1.1a][02集][1080P][AVC][简日双语]"
info = raw_parser(content)
assert info.group == "织梦字幕组"
assert info.title_zh == "尼尔:机械纪元 NieR Automata Ver1.1a"
assert info.title_zh == "尼尔:机械纪元"
assert info.title_en == "NieR Automata Ver1.1a"
assert info.resolution == "1080P"
assert info.episode == 2
assert info.season == 1
@@ -59,3 +60,12 @@ def test_raw_parser():
assert info.resolution == "1080p"
assert info.episode == 33
assert info.season == 1
content = "【极影字幕社】★4月新番 天国大魔境 Tengoku Daimakyou 第05话 GB 720P MP4字幕社招人内详"
info = raw_parser(content)
assert info.group == "极影字幕社"
assert info.title_zh == "天国大魔境"
assert info.title_en == "Tengoku Daimakyou"
assert info.resolution == "720P"
assert info.episode == 5
assert info.season == 1

View File

@@ -6,8 +6,8 @@ def test_torrent_parser():
folder_name = "我内心的糟糕念头(2023)"
season = 1
suffix = ".mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "Boku no Kokoro no Yabai Yatsu S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "我内心的糟糕念头(2023) S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn")[0] == "Boku no Kokoro no Yabai Yatsu S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance")[0] == "我内心的糟糕念头(2023) S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "none") == "[Lilith-Raws] Boku no Kokoro no Yabai Yatsu - 01 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4].mp4"
@@ -15,33 +15,33 @@ def test_torrent_parser():
folder_name = "总之就是非常可爱(2021)"
season = 2
suffix = ".mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "Tonikaku Kawaii S02E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "总之就是非常可爱(2021) S02E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn")[0] == "Tonikaku Kawaii S02E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance")[0] == "总之就是非常可爱(2021) S02E01.mp4"
file_name = "[SweetSub&LoliHouse] Heavenly Delusion - 01 [WebRip 1080p HEVC-10bit AAC ASSx2].mkv"
folder_name = "天国大魔境(2023)"
season = 1
suffix = ".mkv"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "Heavenly Delusion S01E01.mkv"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "天国大魔境(2023) S01E01.mkv"
assert torrent_parser(file_name, folder_name, season, suffix, "pn")[0] == "Heavenly Delusion S01E01.mkv"
assert torrent_parser(file_name, folder_name, season, suffix, "advance")[0] == "天国大魔境(2023) S01E01.mkv"
file_name = "[SBSUB][Kanojo mo Kanojo][01][GB][1080P](456E234).mp4"
folder_name = "女友也要有"
season = 1
suffix = ".mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "Kanojo mo Kanojo S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "女友也要有 S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn")[0] == "Kanojo mo Kanojo S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance")[0] == "女友也要有 S01E01.mp4"
file_name = "[SBSUB][CONAN][1082][V2][1080P][AVC_AAC][CHS_JP](C1E4E331).mp4"
folder_name = "名侦探柯南(1996)"
season = 1
suffix = ".mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "CONAN S01E1082.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "名侦探柯南(1996) S01E1082.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn")[0] == "CONAN S01E1082.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance")[0] == "名侦探柯南(1996) S01E1082.mp4"
file_name = "海盗战记 S01E01.mp4"
folder_name = "海盗战记(2021)"
season = 1
suffix = ".mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "海盗战记 S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "海盗战记(2021) S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn")[0] == "海盗战记 S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance")[0] == "海盗战记(2021) S01E01.mp4"