From 19f4a9ae1b67e84c4f5a4c2cfa2bced9596e154a Mon Sep 17 00:00:00 2001 From: armstjc <70788681+armstjc@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:02:02 -0400 Subject: [PATCH] 0.0.2: The "Betting" Update. - Removed the option to cache data. This may be implemented in a future version. - Implemented `cfbd_json_py.betting.get_cfbd_betting_lines()`, a function that allows a user to get betting lines for a season, a week, and/or for a specific team for the regular season, or postseason. - Changed `cfbd_json_py.utls.get_cfbd_api_token()`` to log, not print out the fact that the CFBD API key the function is trying to find is not present in the current Python environment. - Updated the package version to `0.0.2`. --- .gitignore | 3 +- CHANGELOG.md | 7 + cfbd_json_py/__init__.py | 3 + cfbd_json_py/betting.py | 270 ++++++++++++++++++++++++++++++++---- cfbd_json_py/coaches.py | 3 +- cfbd_json_py/conferences.py | 3 +- cfbd_json_py/draft.py | 9 +- cfbd_json_py/drives.py | 3 +- cfbd_json_py/games.py | 18 +-- cfbd_json_py/metrics.py | 18 +-- cfbd_json_py/players.py | 15 +- cfbd_json_py/plays.py | 15 +- cfbd_json_py/rankings.py | 3 +- cfbd_json_py/ratings.py | 12 +- cfbd_json_py/recruiting.py | 9 +- cfbd_json_py/stats.py | 12 +- cfbd_json_py/teams.py | 15 +- cfbd_json_py/utls.py | 4 +- cfbd_json_py/venues.py | 2 - pyproject.toml | 2 +- 20 files changed, 306 insertions(+), 120 deletions(-) diff --git a/.gitignore b/.gitignore index 98a9072..5042a4e 100644 --- a/.gitignore +++ b/.gitignore @@ -160,4 +160,5 @@ cython_debug/ #.idea/ # test files -test.py \ No newline at end of file +test.py +test.json \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3909c50..8959ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG: cfbd_json_py +## 0.0.2: The "Betting" Update. + +- Removed the option to cache data. This may be implemented in a future version. +- Implemented `cfbd_json_py.betting.get_cfbd_betting_lines()`, a function that allows a user to get betting lines for a season, a week, and/or for a specific team for the regular season, or postseason. +- Changed `cfbd_json_py.utls.get_cfbd_api_token()`` to log, not print out the fact that the CFBD API key the function is trying to find is not present in the current Python environment. +- Updated the package version to `0.0.2`. + ## 0.0.1: The "First Steps" Update - Implemented the core structure of the python package. diff --git a/cfbd_json_py/__init__.py b/cfbd_json_py/__init__.py index 8bf4c1c..0b96eb2 100644 --- a/cfbd_json_py/__init__.py +++ b/cfbd_json_py/__init__.py @@ -1,3 +1,5 @@ +# Loaders +# from cfbd_json_py.loaders import * from cfbd_json_py.betting import * from cfbd_json_py.coaches import * from cfbd_json_py.conferences import * @@ -8,6 +10,7 @@ from cfbd_json_py.players import * from cfbd_json_py.plays import * from cfbd_json_py.rankings import * +from cfbd_json_py.ratings import * from cfbd_json_py.recruiting import * from cfbd_json_py.stats import * from cfbd_json_py.teams import * diff --git a/cfbd_json_py/betting.py b/cfbd_json_py/betting.py index 3a80032..23e7411 100644 --- a/cfbd_json_py/betting.py +++ b/cfbd_json_py/betting.py @@ -1,20 +1,28 @@ +import time +import warnings +from datetime import datetime + +import pandas as pd +import requests +from tqdm import tqdm + from cfbd_json_py.utls import get_cfbd_api_token def get_cfbd_betting_lines( - year: int, + season: int, api_key: str = None, api_key_dir: str = None, game_id: int = None, week: int = None, - season_type: str = "regular", + season_type: str = "regular", # "regular" or "postseason" team: str = None, home_team: str = None, away_team: str = None, conference_abv: str = None, - cache_data: bool = False, - cache_dir: str = None, + # cache_data: bool = False, + # cache_dir: str = None, return_as_dict: bool = False): """ Retrives betting information from the CFBD API for a given season, @@ -23,11 +31,11 @@ def get_cfbd_betting_lines( Parameters ---------- - `year` (int, mandatory): + `season` (int, mandatory): The season you want to retrive betting information from. `api_key` (str, optional): - Optional argument. + Semi-optional argument. If `api_key` is null, this function will attempt to load a CFBD API key from the python environment, or from a file on this computer. If `api_key` is not null, this function will automatically assume that the @@ -84,27 +92,113 @@ def get_cfbd_betting_lines( set `conference_abv` to the abbreviation of the conference you want betting informaiton from. - `cache_data` (bool, semi-optional): - Semi-optional argument. - By default, `cache_data` will be set to `False`. - If `cache_data` is set to `True`, - this function will cache any data downloaded from the CFBD API. - If there is a previously cached request, - this function will attempt to load the previously cached data, - instead of making an API request in most cases. - - `cache_dir` (str, optional): - Optional argument. - If `cache_data` is set to `True`, and `cache_dir` is not null, - this function will try to cache any data downloaded to this custom directory, - instead of caching the data in the user's home directory. - `return_as_dict` (bool, semi-optional): Semi-optional argument. - If you want this function to return the data as a dictionary, + If you want this function to return the data as a dictionary (read: JSON object), instead of a pandas `DataFrame` object, set `return_as_dict` to `True`. + Usage + ---------- + ``` + import time + + from cfbd_json_py.betting import get_cfbd_betting_lines + + cfbd_key = "tigersAreAwsome" # placeholder for your CFBD API Key. + + if cfbd_key != "tigersAreAwsome": + print("Using the user's API key declared in this script for this example.\n\n") + + # Gets all betting info for the 2020 CFB season + print(get_cfbd_betting_lines(api_key=cfbd_key, season=2020)) + time.sleep(5) + print("") + + # Gets all betting info for the 2020 CFB season, in week 2. + print(get_cfbd_betting_lines(api_key=cfbd_key, season=2020, week=2)) + time.sleep(5) + print("") + + # Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.) + print(get_cfbd_betting_lines(api_key=cfbd_key, season=2020, season_type="postseason")) + time.sleep(5) + print("") + + # Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season + print(get_cfbd_betting_lines(api_key=cfbd_key, season=2020, team="Cincinnati")) + time.sleep(5) + print("") + + # Gets all betting info for Ohio Bobcats home games the 2020 CFB season + print(get_cfbd_betting_lines(api_key=cfbd_key, season=2020, home_team="Ohio")) + time.sleep(5) + print("") + + # Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season + print(get_cfbd_betting_lines(api_key=cfbd_key, + season=2020, away_team="Ohio State")) + + # Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season + print(get_cfbd_betting_lines(api_key=cfbd_key, year=2020, conference_abv="ACC")) + time.sleep(5) + print("") + + # You can also tell this function to just return the API call as a Dictionary (read: JSON) object. + print(get_cfbd_betting_lines(api_key=cfbd_key, year=2020, return_as_dict=True)) + + else: + # Alternatively, if the CFBD API key exists in this python environment, + # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(), + # you could just call these functions directly, without setting the API key + # in the script. + print("Using the user's API key suposedly loaded into this python environment for this example.\n\n") + + # Gets all betting info for the 2020 CFB season + print(get_cfbd_betting_lines(season=2020)) + time.sleep(5) + print("") + + # Gets all betting info for the 2020 CFB season, in week 2. + print(get_cfbd_betting_lines(season=2020, week=2)) + time.sleep(5) + print("") + + # Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.) + print(get_cfbd_betting_lines(season=2020, season_type="postseason")) + time.sleep(5) + print("") + + # Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season + print(get_cfbd_betting_lines(season=2020, team="Cincinnati")) + time.sleep(5) + print("") + + # Gets all betting info for Ohio Bobcats home games the 2020 CFB season + print(get_cfbd_betting_lines(season=2020, home_team="Ohio")) + time.sleep(5) + print("") + + # Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season + print(get_cfbd_betting_lines(season=2020, away_team="Ohio State")) + time.sleep(5) + print("") + + # Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season + print(get_cfbd_betting_lines(season=2020, away_team="Ohio State")) + time.sleep(5) + print("") + + # Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season + print(get_cfbd_betting_lines(api_key=cfbd_key, year=2020, conference_abv="ACC")) + time.sleep(5) + print("") + + # You can also tell this function to just return the API call as a Dictionary (read: JSON) object. + print(get_cfbd_betting_lines(api_key=cfbd_key, year=2020, return_as_dict=True)) + + + ``` Returns ---------- A pandas `DataFrame` object with college football betting data, @@ -112,12 +206,138 @@ def get_cfbd_betting_lines( a dictionary object with college football betting data. """ + # now = datetime.now() + betting_df = pd.DataFrame() + row_df = pd.DataFrame() + url = "https://api.collegefootballdata.com/lines?" + + # Input validation + ######################################################################################################################################################################################################## + if game_id != None and season != None: + warnings.warn( + "If you are getting betting information for a single game, only set `game_id` to the game ID, and leave `season` as `NULL`.") + + if season_type == "regular" or season_type == "postseason": + url += f"seasonType={season_type}" + else: + raise ValueError( + "`season_type` must be set to either \"regular\" or \"postseason\".") + + if (game_id == None) and (season == None) and (week != None): + raise ValueError( + "When setting a value for `week`, `season` cannot be null.") + + # if cache_data == True and ((team != None) or (home_team != None) or (away_team != None) or (conference_abv != None)): + # logging.warning( + # "When caching data is enabled for this function, the following inputs are ignored when making the API call:\n-`team`\n-`home_team`\n-`away_team`\n-`conference_abv`") + if api_key != None: real_api_key = api_key del api_key else: real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) - raise NotImplementedError( - 'This function has yet to be implemented by this version.' - ) + if api_key == "tigersAreAwsome": + raise ValueError( + "You actually need to change `cfbd_key` to your CFBD API key.") + elif "Bearer " in real_api_key: + pass + elif "Bearer" in real_api_key: + real_api_key = real_api_key.replace('Bearer', 'Bearer ') + else: + real_api_key = "Bearer " + real_api_key + + # URL builder + ######################################################################################################################################################################################################## + + if game_id != None: + url += f"&gameId={game_id}" + + if season != None: + url += f"&year={season}" + + if week != None: + url += f"&week={week}" + + if team != None: + url += f"&team={team}" + + if home_team != None: + url += f"&home={home_team}" + + if away_team != None: + url += f"&away={away_team}" + + if conference_abv != None: + url += f"&conference={conference_abv}" + + headers = { + 'Authorization': f'{real_api_key}', + 'accept': 'application/json' + } + + response = requests.get(url, headers=headers) + time.sleep(0.1) + + if response.status_code == 200: + pass + elif response.status_code == 401: + raise ConnectionRefusedError( + f'Could not connect. The connection was refused.\nHTTP Status Code 401.' + ) + else: + raise ConnectionError( + f'Could not connect.\nHTTP Status code {response.status_code}' + ) + + json_data = response.json() + + if return_as_dict == True: + return json_data + + for game in tqdm(json_data): + gameId = game['id'] + season = game['id'] + seasonType = game['seasonType'] + startDate = game['startDate'] + homeTeam = game['homeTeam'] + homeConference = game['homeConference'] + homeScore = game['homeScore'] + awayTeam = game['awayTeam'] + awayConference = game['awayConference'] + awayScore = game['awayScore'] + + for line in game['lines']: + row_df = pd.DataFrame( + { + "game_id": gameId, + "season": season, + "season_type": seasonType, + "start_date": startDate, + "home_team": homeTeam, + "home_conference": homeConference, + "home_score": homeScore, + "away_team": awayTeam, + "away_conference": awayConference, + "away_score": awayScore + }, + index=[0] + ) + + row_df["line_provider"] = line['provider'] + row_df["spread"] = line['spread'] + row_df["formatted_spread"] = line['formattedSpread'] + row_df["spread_open"] = line['spreadOpen'] + row_df["over_under"] = line['overUnder'] + row_df["over_under_open"] = line['overUnderOpen'] + row_df["home_moneyline"] = line['homeMoneyline'] + row_df["away_moneyline"] = line['awayMoneyline'] + + betting_df = pd.concat([betting_df, row_df], ignore_index=True) + del row_df + + del gameId, seasonType, startDate, homeTeam, \ + homeConference, homeScore, awayTeam, \ + awayConference, awayScore + + return betting_df diff --git a/cfbd_json_py/coaches.py b/cfbd_json_py/coaches.py index c4e246b..dfd5f87 100644 --- a/cfbd_json_py/coaches.py +++ b/cfbd_json_py/coaches.py @@ -8,8 +8,7 @@ def get_cfbd_coaches_info( year: int = None, min_year: int = None, max_year: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/conferences.py b/cfbd_json_py/conferences.py index e6cee93..5619e1f 100644 --- a/cfbd_json_py/conferences.py +++ b/cfbd_json_py/conferences.py @@ -2,8 +2,7 @@ def get_cfbd_coaches_info( api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ """ diff --git a/cfbd_json_py/draft.py b/cfbd_json_py/draft.py index ddbdf16..8ba81f2 100644 --- a/cfbd_json_py/draft.py +++ b/cfbd_json_py/draft.py @@ -1,8 +1,7 @@ def get_cfbd_nfl_teams( api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -15,8 +14,7 @@ def get_cfbd_nfl_teams( def get_cfbd_nfl_positions( api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -34,8 +32,7 @@ def get_cfbd_nfl_draft_info( college: str = None, conference: str = None, position: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/drives.py b/cfbd_json_py/drives.py index 2a85e4e..feff9a1 100644 --- a/cfbd_json_py/drives.py +++ b/cfbd_json_py/drives.py @@ -12,8 +12,7 @@ def get_cfbd_drives_info( offensive_conference: str = None, defensive_conference: str = None, ncaa_division: str = "fbs", - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/games.py b/cfbd_json_py/games.py index d614b81..70bd925 100644 --- a/cfbd_json_py/games.py +++ b/cfbd_json_py/games.py @@ -10,8 +10,7 @@ def get_cfbd_games( conference: str = None, ncaa_division: str = "fbs", game_id: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -28,8 +27,7 @@ def get_cfbd_team_records( year: int = None, team: str = None, # Must specify either a year or team conference: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -44,8 +42,7 @@ def get_cfbd_season_weeks( year: int, api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -66,8 +63,7 @@ def get_cfbd_game_media_info( conference: str = None, media_type: str = "all", # "tv", "radio", "web", "ppv", or "mobile" ncaa_division: str = "fbs", - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -89,8 +85,7 @@ def get_cfbd_player_game_stats( # `week`, `team`, and/or conference must be not null for this function to work. stat_category: str = None, game_id: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -105,8 +100,7 @@ def get_cfbd_advanced_game_stats( game_id: int, api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ """ diff --git a/cfbd_json_py/metrics.py b/cfbd_json_py/metrics.py index fa36064..ce350a5 100644 --- a/cfbd_json_py/metrics.py +++ b/cfbd_json_py/metrics.py @@ -20,8 +20,7 @@ def get_cfbd_team_ppa_data( # `year` and/or `team` must be not null for this function to work. conference: str = None, exclude_garbage_time: bool = False, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -41,8 +40,7 @@ def get_cfbd_game_ppa_data( conference: str = None, exclude_garbage_time: bool = False, season_type: str = "regular", # "regular" or "postseason" - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -65,8 +63,7 @@ def get_cfbd_game_player_ppa_data( play_threshold: int = None, exclude_garbage_time: bool = False, season_type: str = "regular", # "regular" or "postseason" - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -87,8 +84,7 @@ def get_cfbd_season_player_ppa_data( player_id: int = None, play_threshold: int = None, exclude_garbage_time: bool = False, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -102,8 +98,7 @@ def get_cfbd_game_win_probability_data( game_id: int, api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -120,8 +115,7 @@ def get_cfbd_pregame_win_probability_data( week: int = None, team: str = None, season_type: str = "regular", # "regular" or "postseason" - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/players.py b/cfbd_json_py/players.py index bfcf302..0e1b313 100644 --- a/cfbd_json_py/players.py +++ b/cfbd_json_py/players.py @@ -5,8 +5,7 @@ def cfbd_player_search( position: str = None, team: str = None, year: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -25,8 +24,7 @@ def get_cfbd_player_usage( position: str = None, player_id: int = None, exclude_garbage_time: bool = False, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -42,8 +40,7 @@ def get_cfbd_returning_production( api_key_dir: str = None, team: str = None, conference: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -63,8 +60,7 @@ def get_cfbd_player_season_stats( end_week: int = None, season_type: str = 'regular', # "regular", "postseason", or "both" stat_category: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -78,8 +74,7 @@ def get_cfbd_transfer_portal_data( year: int, api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/plays.py b/cfbd_json_py/plays.py index 769051a..d25d134 100644 --- a/cfbd_json_py/plays.py +++ b/cfbd_json_py/plays.py @@ -13,8 +13,7 @@ def get_cfbd_pbp_data( defensive_conference: str = None, play_type: int = None, ncaa_division: str = "fbs", - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -27,8 +26,7 @@ def get_cfbd_pbp_data( def get_cfbd_pbp_play_types( api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -49,8 +47,7 @@ def get_cfbd_pbp_stats( stat_type_id: int = None, season_type: str = "regular", # "regular", "postseason", or "both" conference: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -63,8 +60,7 @@ def get_cfbd_pbp_stats( def get_cfbd_pbp_stat_types( api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -85,8 +81,7 @@ def get_cfbd_live_pbp_data( game_id: int, api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/rankings.py b/cfbd_json_py/rankings.py index 561e503..b63f8fc 100644 --- a/cfbd_json_py/rankings.py +++ b/cfbd_json_py/rankings.py @@ -5,8 +5,7 @@ def get_cfbd_poll_rankings( api_key_dir: str = None, week: int = None, season_type: str = "regular", # "regular" or "postseason" - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/ratings.py b/cfbd_json_py/ratings.py index aeee451..3883db3 100644 --- a/cfbd_json_py/ratings.py +++ b/cfbd_json_py/ratings.py @@ -5,8 +5,7 @@ def get_cfbd_sp_plus_ratings( year: int = None, team: int = None, # Either `year` or `team` have to be not null for this function to work. - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -23,8 +22,7 @@ def get_cfbd_srs_ratings( team: int = None, # Either `year` or `team` have to be not null for this function to work. conferenece: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -39,8 +37,7 @@ def get_cfbd_sp_plus_conference_ratings( api_key: str = None, api_key_dir: str = None, conference: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -58,8 +55,7 @@ def get_cfbd_elo_ratings( season_type: str = 'regular', # "regular" or "postseason" team: str = None, conference: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/recruiting.py b/cfbd_json_py/recruiting.py index 83ef3e7..6fb4e20 100644 --- a/cfbd_json_py/recruiting.py +++ b/cfbd_json_py/recruiting.py @@ -9,8 +9,7 @@ def get_cfbd_player_recruit_ratings( # Can be "HighSchool", "JUCO", or "PrepSchool" position: str = None, state: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -25,8 +24,7 @@ def get_cfbd_team_recruiting_ratings( api_key_dir: str = None, year: int = None, team: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -43,8 +41,7 @@ def get_cfbd_team_recruiting_group_ratings( end_year: int = None, team: str = None, conference: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/stats.py b/cfbd_json_py/stats.py index 7243a27..adc4106 100644 --- a/cfbd_json_py/stats.py +++ b/cfbd_json_py/stats.py @@ -7,8 +7,7 @@ def get_cfbd_team_season_stats( conference: str = None, start_week: int = None, end_week: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -27,8 +26,7 @@ def get_cfbd_advanced_team_season_stats( exclude_garbage_time: bool = False, start_week: int = None, end_week: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -48,8 +46,7 @@ def get_cfbd_advanced_team_game_stats( opponent: str = None, exclude_garbage_time: bool = False, season_type: str = "regular", # "regular", "postseason", or "both" - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -62,8 +59,7 @@ def get_cfbd_advanced_team_game_stats( def get_cfbd_team_stat_categories( api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/teams.py b/cfbd_json_py/teams.py index d9740eb..924b2b3 100644 --- a/cfbd_json_py/teams.py +++ b/cfbd_json_py/teams.py @@ -2,8 +2,7 @@ def get_cfbd_team_information( api_key: str = None, api_key_dir: str = None, conference_abv: str = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -17,8 +16,7 @@ def get_cfbd_fbs_team_list( api_key: str = None, api_key_dir: str = None, year: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -33,8 +31,7 @@ def get_cfbd_team_rosters( api_key_dir: str = None, team: str = None, year: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -48,8 +45,7 @@ def get_cfbd_team_talent_rankings( api_key: str = None, api_key_dir: str = None, year: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ @@ -66,8 +62,7 @@ def get_cfbd_team_matchup_history( api_key_dir: str = None, min_year: int = None, max_year: int = None, - cache_data: bool = False, - cache_dir: str = None, + return_as_dict: bool = False): """ diff --git a/cfbd_json_py/utls.py b/cfbd_json_py/utls.py index 9adae46..b15c87a 100644 --- a/cfbd_json_py/utls.py +++ b/cfbd_json_py/utls.py @@ -1,6 +1,7 @@ import json import os import secrets +import logging def reverse_cipher_encrypt(plain_text_str: str): @@ -82,7 +83,8 @@ def get_cfbd_api_token(api_key_dir: str = None): key = os.environ['CFBD_API_KEY'] return key except: - print("CFBD key not found in this python environment.\nAttempting to load the API key from a file.") + logging.info( + "CFBD key not found in this python environment.\nAttempting to load the API key from a file.") if api_key_dir != None: with open(f"{api_key_dir}/.cfbd/cfbd.json", "r") as f: diff --git a/cfbd_json_py/venues.py b/cfbd_json_py/venues.py index 493bd72..2b472af 100644 --- a/cfbd_json_py/venues.py +++ b/cfbd_json_py/venues.py @@ -3,8 +3,6 @@ def get_cfbd_venues( api_key: str = None, api_key_dir: str = None, - cache_data: bool = False, - cache_dir: str = None, return_as_dict: bool = False): """ diff --git a/pyproject.toml b/pyproject.toml index c43b6a3..db14f31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "cfbd_json_py" -version = "0.0.1" +version = "0.0.2" readme = "README.md" requires-python = ">=3.10" license = {text = "MIT"}