Skip to content

Commit

Permalink
Merge pull request #386 from EstrellaXD/3.0-dev
Browse files Browse the repository at this point in the history
3.0.10
  • Loading branch information
EstrellaXD authored Jul 10, 2023
2 parents daeb040 + 3a8d9a7 commit 191a833
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
24 changes: 19 additions & 5 deletions backend/src/module/parser/analyser/raw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,32 @@ def name_process(name: str):
split = re.split("-", name)
if len(split) == 1:
split_space = split[0].split(" ")
for idx, item in enumerate(split_space):
language_pattern = []
for item in split_space:
if re.search(r"^[\u4e00-\u9fa5]{2,}", item) is not None:
split_space.remove(item)
split = [item.strip(), " ".join(split_space).strip()]
break
language_pattern.append(1)
elif re.search(r"[a-zA-Z]{2,}", item) is not None:
language_pattern.append(0)
elif re.search(r"[\u0800-\u4e00]{2,}", item) is not None:
language_pattern.append(2)
split = [split_space[0]]
for i in range(1, len(split_space)):
# 如果当前字符串的语言与上一个字符串的语言相同
if language_pattern[i] == language_pattern[i - 1]:
# 合并这两个字符串
split[-1] += ' ' + split_space[i]
else:
# 否则,将当前字符串添加到结果列表中
split.append(split_space[i])
for item in split:
if re.search(r"[\u0800-\u4e00]{2,}", item) and not name_jp:
name_jp = item.strip()
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) and not name_en:
name_en = item.strip()
if name_en not in name:
name_en = None
return name_en, name_zh, name_jp


Expand Down Expand Up @@ -182,5 +196,5 @@ def raw_parser(raw: str) -> Episode | None:


if __name__ == "__main__":
title = "[动漫国字幕组&LoliHouse] THE MARGINAL SERVICE - 08 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]"
title = "【极影字幕·毁片党】LoveLive! SunShine!! 幻日的夜羽 -SUNSHINE in the MIRROR- 第01集 TV版 HEVC_opus 1080p"
print(raw_parser(title))
19 changes: 19 additions & 0 deletions backend/src/test/test_raw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,22 @@ def test_raw_parser():
assert info.resolution == "720P"
assert info.episode == 5
assert info.season == 1

content = "【极影字幕·毁片党】LoveLive! SunShine!! 幻日的夜羽 -SUNSHINE in the MIRROR- 第01集 TV版 HEVC_opus 1080p "
info = raw_parser(content)
assert info.group == "极影字幕·毁片党"
assert info.title_zh == "幻日的夜羽"
assert info.title_en == "LoveLive! SunShine!!"
assert info.resolution == "1080p"
assert info.episode == 1
assert info.season == 1

content = "[ANi] BLEACH 死神 千年血战篇-诀别谭- - 14 [1080P][Baha][WEB-DL][AAC AVC][CHT][MP4]"
info = raw_parser(content)
assert info.group == "ANi"
assert info.title_en == "BLEACH"
assert info.title_zh == "死神 千年血战篇-诀别谭-"
assert info.resolution == "1080P"
assert info.episode == 14
assert info.season == 1

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ click
fastapi
h11
idna
pydantic
pydantic == 1.10
PySocks
qbittorrent-api
requests
Expand Down

0 comments on commit 191a833

Please sign in to comment.