From a446004be71782d8020ce15d86be0cd2444fed19 Mon Sep 17 00:00:00 2001 From: Pete Berryman <70476220+peteb206@users.noreply.github.com> Date: Mon, 13 Jan 2025 09:05:46 -0600 Subject: [PATCH] Test which schools are displaying class years as '25, '26, etc. --- cbn_utils.py | 15 ++++++--------- model.py | 4 +++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cbn_utils.py b/cbn_utils.py index e5a746b..a21eb25 100644 --- a/cbn_utils.py +++ b/cbn_utils.py @@ -21,20 +21,17 @@ def env(key: str): if key_value_tuple[0] == key: return key_value_tuple[1] -print(f'platform.system() --> "{platform.system()}"') -RUNNING_LOCALLY = env('LOCAL') == '1' -now = datetime.now() - -print(platform.system()) +RUNNING_LOCALLY = False if platform.system() == 'Linux' else True # Requests session = requests.Session() -headers = { - 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', - 'X-Requested-With': 'XMLHttpRequest' -} def get(url: str, headers: dict[str, str] = headers, timeout: int = 60, verify: bool = True, attempt: int = 0): + headers = { + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', + 'X-Requested-With': 'XMLHttpRequest' + } + def print_req_result(req: requests.Response): if not isinstance(req, requests.Response): print(f' - timed out after {timeout}s') diff --git a/model.py b/model.py index ae4996f..9057e42 100644 --- a/model.py +++ b/model.py @@ -370,8 +370,10 @@ def __parse_table__(self, html: str): @staticmethod def format_player_class(string: str): # Output Freshman, Sophomore, Junior or Senior - grad_year_map = {"'23": "Senior", "'24": "Junior", "'25": "Sophomore", "'26": "Freshman"} + # TODO: don't want to have this hardcoded. See how many schools are doing this + grad_year_map = {"'25": "Senior", "'26": "Junior", "'27": "Sophomore", "'28": "Freshman"} if string in grad_year_map.keys(): + print('CHECK!') return grad_year_map[string] if ('j' in string) | ('3' in string):