Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds player news to the player_info function in league.py. Player is then initialized with self.news, which is a dictionary with the date the news was published, the headline, and the story. It works with a single payer or with a list of player Ids. For example this program:
players = league.player_info(playerId=[4701230, 4277956], include_news=True)
for player in players:
print(player.news)
returns this:
[{'published': '2025-01-29T15:41:35Z', 'headline': 'Johnson was diagnosed Wednesday with a torn labrum in his left shoulder and will miss the rest of the season, league sources tell NBA reporter Chris Haynes.', 'story': "After breaking out in his first season as a full-time starter in 2023-24, Johnson had taken another step forward in 2024-25 ...
[{'published': '2025-01-31T13:28:53Z', 'headline': "Poole ended with 19 points (5-15 FG, 3-10 3Pt, 6-7 FT), five rebounds and two assists in 25 minutes during Thursday's 134-96 loss to the Lakers.", 'story': "Poole did all he could to help boost Washington in Thursday's contest, leading all Wizards players in scoring and threes ...
Unfortunately there is no way to return multiple player's news with a single api request. So each of these is a seperate api request:
ESPN API Request: url: https://site.api.espn.com/apis/fantasy/v3/games/fba/news/players params: {'playerId': 4701230} headers: None
ESPN API Request: url: https://site.api.espn.com/apis/fantasy/v3/games/fba/news/players params: {'playerId': 4277956} headers: None
This is why I made include_news an optional argument with a default value of False. So that programs that call player_info with a long list of playerIds won't be making a lot of additional api requests unless the news is needed.