From d01c6aab85d6a772839190a72739ed3966a43d68 Mon Sep 17 00:00:00 2001 From: Ching L Date: Sat, 13 Sep 2025 10:22:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E5=A4=9A=E9=87=8D=E6=AF=94=E5=88=86=E7=B4=AF=E7=A7=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20v4.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 update_event_with_score() 和 update_event_with_result() 的比分清理逻辑 - 解决了标题中比分不断累积的问题(如 "✓ 2-0 1-0") - 改进正则表达式,现在能清理所有位置的比分 - 手动修复了9个历史事件的标题 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CHANGELOG.md | 7 +++++++ README.md | 7 ++++++- sync_dota2_matches.py | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a8ef3..f72fb05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v4.3 - 2025-09-13 - 修复标题多重比分问题 +- **🐛 修复多重比分累积问题**: + - 修复了 `update_event_with_score()` 和 `update_event_with_result()` 方法中的比分清理逻辑 + - 原问题:正则表达式 `^(\d+[-:]\d+\s+)+` 无法匹配带有 `✓` 标记的标题,导致比分不断累积 + - 现在使用 `\d+-\d+\s+` 清理所有比分,不限于开头位置 + - 修复了9个历史事件的标题(如 "✓ 2-0 1-0" 改为 "✓ 2-0") + ## v4.2 - 2025-09-13 - 智能合并重复比赛 - **🔀 智能合并重复比赛**: - 新增 `_merge_duplicate_matches()` 方法 diff --git a/README.md b/README.md index 2f92ab2..ea4bfb5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ -# Dota 2 Calendar Sync v4.2 +# Dota 2 Calendar Sync v4.3 自动从 Liquipedia 获取 Dota 2 Tier 1 比赛信息并同步到 Google Calendar,支持自动更新比赛结果、时间变更、智能管理TBD占位事件、自动清理过期和重复比赛。 ## 更新日志 +### v4.3 (2025-09-13) +- 🐛 修复多重比分累积:解决了标题中出现多个比分的问题(如 "✓ 2-0 1-0") +- 🔧 改进比分清理逻辑:现在能正确清理所有位置的比分,不只是开头 +- ✅ 修复了9个历史事件的标题格式 + ### v4.2 (2025-09-13) - 🔀 智能合并重复比赛:自动检测同时间具有共同队伍的比赛并合并(处理队伍名称变体) - 📝 队伍名称标准化:当发现 "OG" 和 "OG Esports" 这样的变体时,保留更长的完整名称 diff --git a/sync_dota2_matches.py b/sync_dota2_matches.py index 236ee5a..40f6923 100644 --- a/sync_dota2_matches.py +++ b/sync_dota2_matches.py @@ -998,9 +998,13 @@ class Dota2CalendarSync: else: description += f"\n{score_text}" - # Update summary + # Update summary - remove ALL existing scores first summary = event.get('summary', '') - summary = re.sub(r'^(\d+[-:]\d+\s+)+', '', summary) + # Remove all score patterns (including those after checkmark) + summary = re.sub(r'\d+-\d+\s+', '', summary) + # Clean up extra spaces + summary = ' '.join(summary.split()) + # Add new score at the beginning summary = f"{match.score} {summary}" event['description'] = description @@ -1056,10 +1060,15 @@ class Dota2CalendarSync: else: description += f"\n{result_text}" - # Update summary + # Update summary - remove ALL existing scores and checkmarks first summary = event.get('summary', '') - summary = re.sub(r'^(\d+[-:]\d+\s+)+', '', summary) + # Remove all score patterns + summary = re.sub(r'\d+-\d+\s+', '', summary) + # Remove checkmark if present summary = re.sub(r'^✓\s+', '', summary) + # Clean up extra spaces + summary = ' '.join(summary.split()) + # Add checkmark and final score summary = f"✓ {match.score} {summary}" event['description'] = description