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

Basketball Add Player News #632

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

JohnDiebold
Copy link
Contributor

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.

@JohnDiebold
Copy link
Contributor Author

@cwendt94 Sorry I know this is my 3rd active pull request. Should be my last for a while. If you want me to combine them or anything just let me know. Thanks!

Copy link

codecov bot commented Feb 2, 2025

Codecov Report

Attention: Patch coverage is 44.00000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 82.71%. Comparing base (107cc52) to head (f0637bd).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
espn_api/requests/espn_requests.py 33.33% 8 Missing ⚠️
espn_api/basketball/league.py 42.85% 4 Missing ⚠️
espn_api/basketball/player.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #632      +/-   ##
==========================================
- Coverage   83.13%   82.71%   -0.42%     
==========================================
  Files          61       61              
  Lines        2306     2326      +20     
==========================================
+ Hits         1917     1924       +7     
- Misses        389      402      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cwendt94
Copy link
Owner

cwendt94 commented Feb 4, 2025

@cwendt94 Sorry I know this is my 3rd active pull request. Should be my last for a while. If you want me to combine them or anything just let me know. Thanks!

No this is great! These are some great features being added!

@cwendt94 cwendt94 merged commit 805ba67 into cwendt94:master Feb 6, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants