Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterain98 committed Sep 13, 2024
1 parent 0157ec7 commit b0ba6ae
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ def announcement_to_banner_meta(chs_ann: dict, all_announcements: list) -> list[
if uigf_pool_type != 500:
time_pattern = (r"(?:〓祈愿介绍〓祈愿时间概率提升(?:角色|武器)(5星)概率提升(?:角色|武器)(4星)"
r"(<t class=\"(?:(t_lc)|(t_gl))\">)?)"
r"(?P<start>(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}))"
r"(?P<start>(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?))"
r"(?:(</t>)?( )?~( )?<t class=\"(?:(t_lc)|(t_gl))\">)"
r"(?P<end>20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)")
else:
time_pattern = (r"(?:〓祈愿介绍〓祈愿时间可定轨5星角色可定轨5星武器"
r"(<t class=\"(?:(t_lc)|(t_gl))\">)?)"
r"(?P<start>(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}))"
r"(?P<start>(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?))"
r"(?:(</t>)?( )?~( )?<t class=\"(?:(t_lc)|(t_gl))\">)"
r"(?P<end>20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)")
try:
Expand All @@ -195,8 +195,8 @@ def announcement_to_banner_meta(chs_ann: dict, all_announcements: list) -> list[
# 更新说明
patch_note = BeautifulSoup([b for b in all_announcements if b["subtitle"] == version +
"版本更新说明"][0]["content"], "html.parser").text
patch_time_pattern = (r"(?:〓更新时间〓<t class=\"t_(gl|lc)\">)"
r"(?P<start>20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})"
patch_time_pattern = (r"(?:〓更新时间〓<t class=\"t_(gl|lc)\"( contenteditable=\"false\")?>)"
r"(?P<start>20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)"
r"(?:</t>开始)")
except IndexError:
try:
Expand All @@ -205,7 +205,7 @@ def announcement_to_banner_meta(chs_ann: dict, all_announcements: list) -> list[
"版本更新维护预告"][0]["content"], "html.parser").text
print(f"Patch note: {patch_note}")
patch_time_pattern = (r"(?:预计将于<t class=\"t_(gl|lc)\"( contenteditable=\"false\")>)"
r"(?P<start>20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})"
r"(?P<start>20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)"
r"(?:</t>进行版本更新维护)")
except IndexError:
if DEBUG:
Expand All @@ -214,7 +214,10 @@ def announcement_to_banner_meta(chs_ann: dict, all_announcements: list) -> list[
print(b["content"])
print("No update log found; game is most likely under maintenance")
exit(500)
start_time = re.search(patch_time_pattern, patch_note).group("start")
try:
start_time = re.search(patch_time_pattern, patch_note).group("start")
except AttributeError:
raise ValueError(f"Unknown time format\nPatch Note: {patch_note}\nPattern: {patch_time_pattern}")
print(f"Found patch time: {start_time}")
else:
version = "99.99"
Expand Down

0 comments on commit b0ba6ae

Please sign in to comment.