-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into snyk-fix-ae24e85764c9ada6be83f7eca7a90b4b
- Loading branch information
Showing
29 changed files
with
3,819 additions
and
2,693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,54 @@ | ||
import os, time | ||
if not hasattr(os, 'add_dll_directory'): | ||
def add_dll_directory(path): | ||
pass | ||
from mongoengine import connect | ||
from src.models.seasons import(SeasonInfo) | ||
from src.models.team_info import(coach, rgb_color, team, team_color, TeamInfo) | ||
if not hasattr(os, 'add_dll_directory'): | ||
def add_dll_directory(path): | ||
pass | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
connection_string = os.getenv('MONGODB_URL') | ||
if not connection_string: | ||
raise Exception("MONGO_CONNECTION_STRING must be set") | ||
connect(db='Current_Season', host=connection_string) | ||
|
||
from datetime import datetime | ||
import requests | ||
API_KEY = os.getenv('APIKEY') | ||
URL = "http://api.sportradar.us/nfl/official/trial/v7/en/seasons/{SEASONYEAR}/{SEASONTYPE}/teams/{TeamID}/statistics.json?api_key={API_KEY}" | ||
TEAMID = list({team.id for team in TeamInfo.objects.only("id")}) | ||
SEASONYEAR = list({season.year for season in SeasonInfo.objects.only("year")}) | ||
SEASONTYPE = list( | ||
{season["type"] for season in SeasonInfo.objects.only("type")} | ||
) | ||
print(SEASONYEAR) | ||
print(TEAMID) | ||
print(SEASONTYPE) | ||
|
||
counter = 0 | ||
try: | ||
for team_id in TEAMID: | ||
for year in SEASONYEAR: | ||
for season_type in SEASONTYPE: | ||
constructed_url = URL.format(SEASONYEAR=year, SEASONTYPE=season_type, TeamID=team_id) | ||
print(datetime.now(), "Constructed URL:", constructed_url) | ||
try: | ||
response = requests.get(constructed_url) | ||
if response.status_code != 200: | ||
print(f"Error: API call to {constructed_url} returned status code: {response.status_code}") | ||
except requests.exceptions.RequestException as req_e: | ||
print(f"API request error for {constructed_url}. Error: {req_e}") | ||
counter += 1 | ||
if counter >= 40: | ||
break | ||
if counter >= 40: | ||
break | ||
if counter >= 40: | ||
break | ||
except Exception as e: | ||
print(f"Error: {str(e)}") | ||
import os | ||
from security import safe_requests | ||
|
||
if not hasattr(os, 'add_dll_directory'): | ||
def add_dll_directory(path): | ||
pass | ||
from mongoengine import connect | ||
from src.models.seasons import(SeasonInfo) | ||
from src.models.team_info import(TeamInfo) | ||
if not hasattr(os, 'add_dll_directory'): | ||
def add_dll_directory(path): | ||
pass | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
connection_string = os.getenv('MONGODB_URL') | ||
if not connection_string: | ||
raise Exception("MONGO_CONNECTION_STRING must be set") | ||
connect(db='Current_Season', host=connection_string) | ||
|
||
from datetime import datetime | ||
import requests | ||
API_KEY = os.getenv('APIKEY') | ||
URL = "http://api.sportradar.us/nfl/official/trial/v7/en/seasons/{SEASONYEAR}/{SEASONTYPE}/teams/{TeamID}/statistics.json?api_key={API_KEY}" | ||
TEAMID = list({team.id for team in TeamInfo.objects.only("id")}) | ||
SEASONYEAR = list({season.year for season in SeasonInfo.objects.only("year")}) | ||
SEASONTYPE = list( | ||
{season["type"] for season in SeasonInfo.objects.only("type")} | ||
) | ||
print(SEASONYEAR) | ||
print(TEAMID) | ||
print(SEASONTYPE) | ||
|
||
counter = 0 | ||
try: | ||
for team_id in TEAMID: | ||
for year in SEASONYEAR: | ||
for season_type in SEASONTYPE: | ||
constructed_url = URL.format(SEASONYEAR=year, SEASONTYPE=season_type, TeamID=team_id) | ||
print(datetime.now(), "Constructed URL:", constructed_url) | ||
try: | ||
response = safe_requests.get(constructed_url) | ||
if response.status_code != 200: | ||
print(f"Error: API call to {constructed_url} returned status code: {response.status_code}") | ||
except requests.exceptions.RequestException as req_e: | ||
print(f"API request error for {constructed_url}. Error: {req_e}") | ||
counter += 1 | ||
if counter >= 40: | ||
break | ||
if counter >= 40: | ||
break | ||
if counter >= 40: | ||
break | ||
except Exception as e: | ||
print(f"Error: {str(e)}") |
Oops, something went wrong.