Skip to content

Commit

Permalink
added init nba
Browse files Browse the repository at this point in the history
  • Loading branch information
byfarm committed Nov 20, 2023
1 parent 338d1dc commit 98f777f
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 7 deletions.
31 changes: 31 additions & 0 deletions NBA.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name,prefix_1
Boston Celtics,bos
Brooklyn Nets,bkn
New York Knicks,ny
Philadelphia 76ers,phi
Toronto Raptors,tor
Golden State Warriors,gs
Los Angeles Clippers,lac
Los Angeles Lakers,lal
Phoenix Suns,phx
Sacramento Kings,sac
Chicago Bulls,chi
Cleveland Cavaliers,cle
Detroit Pistons,det
Indiana Pacers,ind
Milwaukee Bucks,mil
Dallas Mavericks,dal
Houston Rockets,hou
Memphis Grizzlies,mem
New Orleans Pelicans,no
San Antonio Spurs,sa
Atlanta Hawks,atl
Charlotte Hornets,cha
Miami Heat,mia
Orlando Magic,orl
Washington Wizards,was
Denver Nuggets,den
Minnesota Timberwolves,min
Oklahoma City Thunder,okc
Portland Trail Blazers,por
Utah Jazz,uta
Binary file modified __pycache__/name_comparitor.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/write.cpython-311.pyc
Binary file not shown.
9 changes: 8 additions & 1 deletion name_comparitor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pandas as pd
from devtools import debug
names_db: list[list[str]] = []
nfl_enum = pd.read_csv("~/coding/python/betting/enums.csv")
nba_enum = pd.read_csv("~/coding/python/betting/NBA.csv")


def check_names(names_to_check: list[str], name_index: int = None):
Expand Down Expand Up @@ -60,8 +62,14 @@ def add_names(names: list[str]):
if namecheck(name, nfl_enum["Name"]):
idx = list(nfl_enum["Name"]).index(name)
name += " " + list(nfl_enum["Abbreviation"])[idx]

elif namecheck(name, nba_enum["name"]):
idx = list(nba_enum["name"]).index(name)
name += " " + list(nba_enum["prefix_1"])[idx]

name = name.lower()
names_db.append(name.split(" "))
debug(names_db)


def namecheck(name, lis):
Expand All @@ -72,7 +80,6 @@ def namecheck(name, lis):


if __name__ == "__main__":
from devtools import debug
names_in = ["byron farmar"]
names_check = ["byron george Farmar", "sarah Jones", "Byron Jones"]
add_names(names_check)
Expand Down
Binary file modified scrapers/__pycache__/draftkings.cpython-311.pyc
Binary file not shown.
Binary file modified scrapers/__pycache__/pinnacle.cpython-311.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion scrapers/draftkings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async def parse_draftkings(json_data: dict):

matchup: list = []
for player in section.get("outcomes", []):
# debug(player)
name = player.get("label", "")
odds = int(player.get("oddsAmerican", 0))
if name in [x.name for x in all_bets]:
Expand All @@ -53,7 +54,7 @@ async def scrape_draftkings(url: str = None):


if __name__ == "__main__":
url = "https://sportsbook-us-co.draftkings.com/sites/US-CO-SB/api/v5/eventgroups/88808?format=json"
url = "https://sportsbook-us-co.draftkings.com/sites/US-CO-SB/api/v5/eventgroups/42648?format=json"
# url = None
res = asyncio.run(scrape_draftkings(url))
debug(res)
2 changes: 1 addition & 1 deletion scrapers/pinnacle.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def scrape_pinnacle(url: str = None):


if __name__ == "__main__":
url = "https://guest.api.arcadia.pinnacle.com/0.1/leagues/889/markets/straight"
url = "https://guest.api.arcadia.pinnacle.com/0.1/leagues/487/markets/straight"
import asyncio
res = asyncio.run(scrape_pinnacle(url))
debug(res)
14 changes: 14 additions & 0 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@

"Pointsbet": "https://api.nj.pointsbet.com/api/v2/sports/tennis/events/nextup?limit=50""",
},

"NBA": {
# "Ceasers": None,

"Draftkings": "https://sportsbook-us-co.draftkings.com/sites/US-CO-SB/api/v5/eventgroups/42648?format=json",

# "Betrivers": None,
# "MGM": None,
# "Fanduel": None,

"Pinnacle": "https://guest.api.arcadia.pinnacle.com/0.1/leagues/487/markets/straight",

# "Pointsbet": None,
}
}

scraping_functions: dict = {
Expand Down
13 changes: 9 additions & 4 deletions write.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def combine_data(sport, **kwargs):
"UFC": 1,
"TEN": 0,
"NFL": 1,
"NBA": 1,
}
name_change = {
"Los Angeles Rams": "Angeles LAR",
Expand All @@ -99,7 +100,11 @@ def combine_data(sport, **kwargs):
"NY Jets": "NYJ Jets",
"New York Jets": "NYJ Jets",
"NY Giants": "NYG Giants",
"New York Giants": "NYG Giants"
"New York Giants": "NYG Giants",
"LA Clippers": "LAC Clippers",
"Los Angeles Clippers": "LAC Clippers",
"LA Lakers": "LAL Lakers",
"Los Anngeles Lakers": "LAL Lakers",
}
big_dict = {}
for key, value in kwargs.items():
Expand All @@ -110,12 +115,12 @@ def combine_data(sport, **kwargs):
val.name = name_change[val.name]
# get the name stored in the database
name = check_single_name(val.name, name_indexes[sport])
# opp_name = check_single_name(val.matchup.name, name_indexes[sport])
opp_name = check_single_name(val.matchup.name, name_indexes[sport])

# if the matchup not in, skip
if not name:
# print(name, opp_name)
# print(val.name, val.matchup.name)
print(name, opp_name)
print(val.name, val.matchup.name)
continue

name = name.title()
Expand Down

0 comments on commit 98f777f

Please sign in to comment.