diff --git a/fpl/fpl.py b/fpl/fpl.py index 259b980..04befae 100644 --- a/fpl/fpl.py +++ b/fpl/fpl.py @@ -262,7 +262,7 @@ async def get_player(self, player_id, players=None, gameweek=None, include_summa return Player(player, self.session) - async def get_players(self, player_ids=None, include_summary=False, include_live=None, + async def get_players(self, player_ids=None, include_summary=False, include_live=False, return_json=False): """Returns either a list of *all* players, or a list of players whose IDs are in the given ``player_ids`` list. @@ -287,8 +287,14 @@ async def get_players(self, player_ids=None, include_summary=False, include_live if not player_ids: player_ids = [player["id"] for player in players.values()] + current_gameweek_id = getattr(self, "current_gameweek") + gameweeks = getattr(self, "events") + current_gameweek = gameweeks[current_gameweek_id] + current_gameweek_finished = current_gameweek["finished"] + include_live = include_live and not current_gameweek_finished + if include_live: - gameweek = await self.get_gameweek(getattr(self, "current_gameweek"), include_live=True) + gameweek = await self.get_gameweek(current_gameweek_id, include_live=include_live) tasks = [asyncio.ensure_future( self.get_player( diff --git a/fpl/models/player.py b/fpl/models/player.py index 098e993..40167a4 100644 --- a/fpl/models/player.py +++ b/fpl/models/player.py @@ -25,6 +25,8 @@ def __init__(self, player_information, session): self._session = session for k, v in player_information.items(): setattr(self, k, v) + self.did_not_play = False + self.live_score = getattr(self, "event_points") @property async def games_played(self): diff --git a/fpl/models/user.py b/fpl/models/user.py index 42c32a6..063b5ec 100644 --- a/fpl/models/user.py +++ b/fpl/models/user.py @@ -290,19 +290,19 @@ async def get_live_score(self, players): captain = next(pick["element"] for pick in picks if pick["is_captain"]) try: - vice_captain = next( - pick["element"] for pick in picks if pick["is_vice_captain"] and pick["multiplier"] == 1) - # only if multiplier == 1, i.e. vice-captain not already applied by FPL + vice_captain = next(pick["element"] for pick in picks if pick["is_vice_captain"]) except StopIteration: vice_captain = None captain_points = players[captain].live_score - if captain in subs_out and vice_captain: + if captain in subs_out + subs: captain_points = players[vice_captain].live_score if active_chip == "3xc": # for triple captain chip captain_points *= 2 + print(sum(first_xi_live_scores), captain_points, points_hit) + return sum(first_xi_live_scores) + captain_points - points_hit async def get_live_total_points(self, players):