Skip to content

Commit bbac5ef

Browse files
Enhance MatcherinoScraper: improve team member extraction logic, add fallback for team names, and include additional member data for better compatibility and debugging.
1 parent 3cbae26 commit bbac5ef

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

matcherino_scraper.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,50 @@ async def get_teams_data(self, tournament_id: Optional[str] = None) -> List[Dict
138138
# Format the team data to match the expected structure
139139
teams_data = []
140140
for team in teams_raw:
141+
# Get team name, with fallback
141142
team_name = team.get('name', 'Unknown Team')
142143

143-
# Extract team members
144+
# Extract team members - checking both 'members' and possibly nested 'team.members'
144145
members = []
145-
if 'participants' in team and isinstance(team['participants'], list):
146-
for participant in team['participants']:
147-
if 'displayName' in participant:
148-
members.append(participant['displayName'])
146+
147+
# Check for members directly in the team object
148+
if 'members' in team and isinstance(team['members'], list):
149+
for member in team['members']:
150+
if 'displayName' in member:
151+
display_name = member['displayName'].strip()
152+
members.append({
153+
'name': display_name,
154+
'user_id': member.get('userId', ''),
155+
'auth_id': member.get('authId', ''),
156+
'auth_provider': member.get('authProvider', ''),
157+
'is_captain': member.get('captain', False),
158+
'game_username': member.get('participantInfo', {}).get('gameUsername', '')
159+
})
160+
161+
# If no members found and there's a nested team structure, check there
162+
if not members and 'team' in team and isinstance(team['team'], dict) and 'members' in team['team']:
163+
for member in team['team']['members']:
164+
if 'displayName' in member:
165+
display_name = member['displayName'].strip()
166+
members.append({
167+
'name': display_name,
168+
'user_id': member.get('userId', ''),
169+
'auth_id': member.get('authId', ''),
170+
'auth_provider': member.get('authProvider', ''),
171+
'is_captain': member.get('captain', False),
172+
'game_username': '' # No game username in this structure
173+
})
174+
175+
# Format for compatibility with existing code
176+
member_names = [member['name'] for member in members]
149177

150178
teams_data.append({
151179
'name': team_name,
152-
'members': members,
153-
'team_id': team.get('id', None), # Include team ID if available
180+
'members': member_names,
181+
'members_data': members, # Full member data
182+
'team_id': team.get('id') or (team.get('team', {}) or {}).get('id', None),
183+
'bounty_team_id': team.get('bountyTeamId', None),
184+
'created_at': team.get('createdAt', None),
154185
'raw_data': team # Include the raw data for debugging/future use
155186
})
156187

0 commit comments

Comments
 (0)