Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add features to matchups; Fix a bug in player parsing #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ff_espn_api/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ def scoreboard(self, week: int = None) -> List[Matchup]:

for team in self.teams:
for matchup in matchups:
if matchup.winner == team.team_id:
matchup.winner = team
if matchup.home_team == team.team_id:
matchup.home_team = team
elif matchup.away_team == team.team_id:
Expand Down
8 changes: 8 additions & 0 deletions ff_espn_api/matchup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
WINNERS_BRACKET = 'WINNERS_BRACKET'


class Matchup(object):
'''Creates Matchup instance'''
def __init__(self, data):
Expand All @@ -7,6 +10,9 @@ def __init__(self, data):
def __repr__(self):
return 'Matchup(%s, %s)' % (self.home_team, self.away_team, )

def is_playoff(self):
return WINNERS_BRACKET == self.playoff_tier_type

def _fetch_matchup_info(self):
'''Fetch info for matchup'''
self.home_team = self.data['home']['teamId']
Expand All @@ -18,3 +24,5 @@ def _fetch_matchup_info(self):
if 'away' in self.data:
self.away_team = self.data['away']['teamId']
self.away_score = self.data['away']['totalPoints']
self.playoff_tier_type = self.data.get('playoffTierType', 'regular')
self.winner = self.home_team if self.data['winner'] == 'HOME' else self.away_team