From 253277620c5dab6f507eeb43373e500214a9934e Mon Sep 17 00:00:00 2001 From: Ching L Date: Mon, 8 Sep 2025 14:00:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=8E=86=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=A0=87=E9=A2=98=E4=B8=AD=E9=87=8D=E5=A4=8D=E6=AF=94?= =?UTF-8?q?=E5=88=86=E7=9A=84=E9=97=AE=E9=A2=98=20v3.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复了更新比赛比分时可能出现重复比分的bug(如 '0-2 0-1') - 改进比分更新逻辑,确保标题中只显示一个比分 - 更新 README 和 CHANGELOG 到 v3.8 🤖 Generated with Claude Code Co-Authored-By: Claude --- CHANGELOG.md | 11 +++++++++++ README.md | 2 +- sync_dota2_matches.py | 15 +++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0175be7..0c4b105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## v3.8 - 2025-09-08 - 修复重复比分显示问题 +- **修复标题中重复比分的问题**: + - 修复了在更新比赛比分时可能出现重复比分的bug(如 "0-2 0-1") + - 改进了 `update_event_with_score` 方法,使用更强的正则表达式清理多个比分 + - 改进了 `update_event_with_result` 方法,先清理所有旧比分再添加最终比分 +- **增强比分更新逻辑**: + - 进行中比分更新时会正确移除之前的所有比分 + - 完成比赛更新时会先清理进行中的比分,再添加最终结果 + - 确保标题中始终只显示一个比分 + ## v3.7 - 2025-09-08 - 增强重复事件处理和TBD管理 - **改进TBD比赛ID生成**: - TBD vs TBD比赛现在使用时间戳生成唯一ID,避免重复创建 @@ -132,6 +142,7 @@ | v3.5 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | v3.6 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | v3.7 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| v3.8 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ## 使用建议 diff --git a/README.md b/README.md index 6adf776..d1c15eb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Dota 2 Calendar Sync v3.7 +# Dota 2 Calendar Sync v3.8 自动从 Liquipedia 获取 Dota 2 Tier 1 比赛信息并同步到 Google Calendar,支持自动更新比赛结果、时间变更、智能管理TBD占位事件和自动清理重复比赛。 diff --git a/sync_dota2_matches.py b/sync_dota2_matches.py index 6c0456d..c9f4479 100644 --- a/sync_dota2_matches.py +++ b/sync_dota2_matches.py @@ -608,8 +608,8 @@ class Dota2CalendarSync: # Update the summary to show current score (without checkmark) summary = event.get('summary', '') - # Remove any existing score - summary = re.sub(r'^\d+[-:]\d+\s+', '', summary) + # Remove any existing score (including multiple scores) + summary = re.sub(r'^(\d+[-:]\d+\s+)+', '', summary) # Add new score at the beginning score = match_data.get('score', '?-?') summary = f"{score} {summary}" @@ -661,10 +661,13 @@ class Dota2CalendarSync: # Update the summary to show it's completed with result summary = event.get('summary', '') - if '✓' not in summary: - # Add checkmark and score right after it - score = match_data.get('score', '?-?') - summary = f"✓ {score} {summary}" + # First remove any existing scores (in-progress scores) + summary = re.sub(r'^(\d+[-:]\d+\s+)+', '', summary) + # Remove any existing checkmark + summary = re.sub(r'^✓\s+', '', summary) + # Add checkmark and final score + score = match_data.get('score', '?-?') + summary = f"✓ {score} {summary}" # Update the event event['description'] = description