修复TBD比赛错误标记为完成的问题
Some checks failed
continuous-integration/drone/push Build is failing

- 修改比分解析逻辑,只匹配破折号而不匹配冒号,避免将时间(19:00)误识别为比分
- 添加额外检查,确保不会将日期格式误识别为比分
- 添加TBD比赛保护机制,确保TBD vs TBD的比赛永远不会被标记为有比分或已完成
- 如果错误解析了TBD比赛的比分,会自动删除

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ching 2025-09-07 11:57:21 +08:00
parent 6fd21a64b9
commit 81eb9ba403

View File

@ -165,14 +165,16 @@ class Dota2CalendarSync:
# If score not found in structure, try text pattern
if not has_score:
text = parent.get_text()
score_pattern = re.search(r'(\d{1,2})[:|-](\d{1,2})', text)
# Only look for dash pattern (not colon) to avoid matching time
score_pattern = re.search(r'(\d{1,2})-(\d{1,2})', text)
if score_pattern:
score1 = int(score_pattern.group(1))
score2 = int(score_pattern.group(2))
# Validate it's a reasonable game score and not time
# Validate it's a reasonable game score
if 0 <= score1 <= 5 and 0 <= score2 <= 5 and (score1 + score2) > 0:
# Make sure it's not a time pattern (HH:MM)
if not re.search(r'\d{1,2}:\d{2}\s*(?:CEST?|UTC|[AP]M)', text[max(0, score_pattern.start()-10):score_pattern.end()+10]):
# Additional check: make sure this isn't part of a date (e.g., 2025-01-14)
surrounding_text = text[max(0, score_pattern.start()-5):score_pattern.end()+5]
if not re.search(r'\d{4}-\d{1,2}-\d{1,2}', surrounding_text):
has_score = True
match_data['score'] = f"{score1}-{score2}"
score_match = score_pattern
@ -219,6 +221,15 @@ class Dota2CalendarSync:
# Mark if has score and if completed
if has_score:
# TBD vs TBD matches should NEVER be marked as having a score or completed
if match_data.get('team1') == 'TBD' and match_data.get('team2') == 'TBD':
has_score = False
match_data['completed'] = False
match_data['has_score'] = False
# Remove any incorrectly parsed score
if 'score' in match_data:
del match_data['score']
else:
# Score already set above, extract score values
score_parts = re.match(r'(\d+)-(\d+)', match_data['score'])
if score_parts: