Skip to content

Commit

Permalink
started working on data.py for pulling info by sleeper user_id
Browse files Browse the repository at this point in the history
  • Loading branch information
brownjf2027 committed Apr 21, 2024
1 parent 147fd46 commit 095a2a6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
33 changes: 32 additions & 1 deletion data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

PLAYERS_URL = "https://api.sleeper.app/v1/players/nfl"
DRAFT_URL = "https://api.sleeper.app/v1/draft/"
USER_URL = "GET https://api.sleeper.app/v1/user/"
USER_URL = "https://api.sleeper.app/v1/user/"
LEAGUES_BY_USER = "https://api.sleeper.app/v1/user/<user_id>/leagues/nfl/<season>"
DRAFTS_BY_USER = "https://api.sleeper.app/v1/user/<user_id>/drafts/nfl/<season>"
TOP_X_PLAYERS = 500


Expand Down Expand Up @@ -83,6 +85,28 @@ def get_csv():
return players_data


def get_leagues(year, user_id):
leagues_url = LEAGUES_BY_USER.replace("<user_id>", user_id)
leagues_url = leagues_url.replace("<season>", str(year))
parameters = {}
response = requests.get(leagues_url, params=parameters)
response.raise_for_status()
data = response.json()
print(data)
return data


def get_drafts(year, user_id):
drafts_url = DRAFTS_BY_USER.replace("<user_id>", user_id)
drafts_url = drafts_url.replace("<season>", str(year))
parameters = {}
response = requests.get(drafts_url, params=parameters)
response.raise_for_status()
data = response.json()
print(data)
return data


def top_players():
with open("top_players.json", "r") as data_file:
players_data = json.load(data_file)
Expand Down Expand Up @@ -117,3 +141,10 @@ def get_top_players():
# get_top_players()
# get_draft("1071375774982234112")
# get_draft_picks("1052865939722690560")

# try:
# user_data = get_user("jfbrown")
# drafts = get_drafts("2024", user_data["user_id"])
# print(drafts)
# except requests.RequestException:
# print("not found")
2 changes: 1 addition & 1 deletion templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1 class="text-body-emphasis">Enjoy using it?</h1>
<!-- data-text="Buy me a coffee" data-outline-color="#fff" data-font-color="#ffffff"-->
<!-- data-coffee-color="#71463d"></script>-->
<!-- </div>-->
<a class="btn btn-primary btn-lg" href="https://www.buymeacoffee.com/jfbrown">
<a class="btn btn-primary btn-lg mb-5" href="https://www.buymeacoffee.com/jfbrown">
<svg class="m-l-5" width="20px" height="28px" viewBox="0 0 884 1279" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M791.109 297.518L790.231 297.002L788.201 296.383C789.018 297.072 790.04 297.472 791.109 297.518Z"
Expand Down
3 changes: 2 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ <h3 class="px-2"> Sleeper Tiers </h3>
</div>
<div class="col-lg-6">
<h1 class="display-5 fw-bold text-emphasis lh-1 mb-3">Track player tiers live in your Sleeper draft</h1>
<p class="lead">Overall, while fantasy football projections can provide valuable insights and guidance
<h3 class="text-info" style="display: inline;"> No login or account required!</h3>
<p class="lead">While fantasy football projections can provide valuable insights and guidance
for fantasy team
managers, they should be used as just one tool among many.</p>
<p class="lead">If you like to categorize players into Tiers for drafts, this tool is designed for you.
Expand Down

0 comments on commit 095a2a6

Please sign in to comment.