diff --git a/main.py b/main.py index e5ad95b..9cb390d 100644 --- a/main.py +++ b/main.py @@ -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"()?)" - r"(?P(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}))" + r"(?P(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?))" r"(?:()?( )?~( )?)" r"(?P20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)") else: time_pattern = (r"(?:〓祈愿介绍〓祈愿时间可定轨5星角色可定轨5星武器" r"()?)" - r"(?P(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}))" + r"(?P(\d.\d版本更新后)|(20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?))" r"(?:()?( )?~( )?)" r"(?P20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)") try: @@ -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"(?:〓更新时间〓)" - r"(?P20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})" + patch_time_pattern = (r"(?:〓更新时间〓)" + r"(?P20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)" r"(?:开始)") except IndexError: try: @@ -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"(?:预计将于)" - r"(?P20\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})" + r"(?P20\d{2}/\d{2}/\d{2} \d{2}:\d{2}(:\d{2})?)" r"(?:进行版本更新维护)") except IndexError: if DEBUG: @@ -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"