-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBetMGM.py
73 lines (58 loc) · 1.9 KB
/
BetMGM.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import json
import os
from Utils import Utils
"""
Handles data scraped from Bovada.lv
"""
class BetMGM:
utils = None
def __init__(self, year):
self.utils = Utils()
self.heatmap_path = "./data/{}/heatmap_data.csv".format(year)
self.betMGM_exact_score_odds_json_path = "./data/{}/BetMGM_exact_score_odds.json".format(year)
self.betMGM_squares_odds_json_path = "./data/{}/BetMGM_squares_odds.json".format(year)
def get_squares_odds(self):
return self.get_odds(self.betMGM_squares_odds_json_path)
def get_exact_score_odds(self):
return self.get_odds(self.betMGM_exact_score_odds_json_path)
"""
Returns
{
"10,7": {
"name": "Chiefs 10 - Eagles 7",
"odds": 50000
},
"13,10": {
"name": "Chiefs 13 - Eagles 10",
"odds": 20000
},
...
}
"""
def get_odds(self, path="./random_path"):
if not os.path.exists(path):
return {}
contents = self.utils.read_json(path)['results']
to_return = {}
for row in contents:
bet_name = row['name']['value']
scores = self.extract_scores(bet_name)
scores_str = self.utils.score_to_str(scores[0], scores[1])
to_return[scores_str] = {
"name": bet_name,
"odds": row['americanOdds']
}
return to_return
"""
Provided scores string "Chiefs 10 - Eagles 7", return [10, 7]
"""
def extract_scores(self, scores_str):
split_str = scores_str.split(" - ")
first_score = int(split_str[0].split(" ")[-1])
second_score = int(split_str[1].split(" ")[-1])
return [first_score, second_score]
if __name__=="__main__":
utils = Utils()
year = utils.ask_year()
analyzer = BetMGM(year)
analyzer.get_odds()