def place(self, data, cookies, headers): if cookies and headers and data: response = requests.post( 'https://sports.bovada.lv/services/sports/bet/betslip', headers=headers, cookies=cookies, data=data) if response.status_code == 200: status = search_dictionary_for_certain_keys( "response", response.json()) if status: print "got status" key = search_dictionary_for_certain_keys("key", status) if key: print "got the key" r = requests.get( "https://sports.bovada.lv/services/sports/bet/betslip/{}" .format(key)) if bet_went_through(r.json()): return True else: return False try: print response.keys() print response.json() except Exception, e: print e return True else: print response.reason print response.status_code
def place(self, data, cookies, headers): if cookies and headers and data: response = requests.post('https://sports.bovada.lv/services/sports/bet/betslip', headers=headers, cookies=cookies, data=data) if response.status_code == 200: status = search_dictionary_for_certain_keys("response", response.json()) if status: print "got status" key = search_dictionary_for_certain_keys("key", status) if key: print "got the key" r = requests.get("https://sports.bovada.lv/services/sports/bet/betslip/{}".format(key)) if bet_went_through(r.json()): return True else: return False try: print response.keys() print response.json() except Exception, e: print e return True else: print response.reason print response.status_code
def create_from_center_content(cls, content_center): match = search_dictionary_for_certain_keys("items", content_center)[0] outcome_objects_for_match = [] game_sport = match['sport'] game_id = int(match['id']) description = match['description'] startTime = match['startTime'] competitors = match['competitors'] home_team_abbreviation = search_dictionary_for_certain_keys("abbreviation", competitors[0]) home_team_short_name = search_dictionary_for_certain_keys("shortName", competitors[0]) home_team_full_name = search_dictionary_for_certain_keys("description", competitors[0]) away_team_short_name = search_dictionary_for_certain_keys("shortName", competitors[1]) away_team_abbreviation= search_dictionary_for_certain_keys("abbreviation", competitors[1]) away_team_full_name = search_dictionary_for_certain_keys("description", competitors[1]) game_link = "https://sports.bovada.lv{}".format(match['link']) type_ = match['type'] displayGroups= match['displayGroups'] for group in displayGroups: #if the group is not a gameline we'll skip over it. if group['description'] != "Game Lines": pass else: betting_lines = [x for x in group["itemList"]] for line in betting_lines: outcomes = OutCome.create_from_betting_line(line) for outcome in outcomes: outcome_objects_for_match.append(outcome) bmatch = BovadaMatch( sport=game_sport, description=description, startTime=startTime, home_team_short_name=home_team_short_name, home_team_full_name = home_team_full_name, home_team_abbreviation = home_team_abbreviation, away_team_shortname = away_team_short_name, away_team_abbreviation = away_team_abbreviation, away_team_full_name = away_team_full_name, game_link=game_link, type=type_, game_id=game_id, outcomes=outcome_objects_for_match) return bmatch
def bulk_create_from_center_content(cls, center_content): bmatches = [] try: gamelines = search_dictionary_for_certain_keys("items", center_content)[ 0 ] # index 0 is gamelines index 1 is futures except (IndexError, TypeError): return [] try: matches = gamelines["itemList"]["items"] except (KeyError): return [] else: for match in matches: game_sport = "" game_id = None description = "" startTime = None competitors = [] home_team_abbreviation = "" home_team_short_name = "" home_team_full_name = "" away_team_full_name = "" away_team_short_name = "" away_team_abbreviation = "" game_link = "" outcome_objects_for_match = [] try: game_sport = match["sport"] except KeyError, e: pass try: game_id = int(match["id"]) except KeyError, e: pass try: description = match["description"] except KeyError, e: pass
def parse_special_response(response, action): if action == "balance": return int(search_dictionary_for_certain_keys("availableBalance", response.json())["amount"]) elif action == "summary": return response.json() elif action == "wallets": return response.json() elif action == "open_bets": outstanding_bet_amount = 0 total_odds = 0 try: items = response.json()["items"] except KeyError, e: items = None if items: for item in items: print item try: riskAmount = item["riskAmount"] except KeyError, e: riskAmount = None try: toWinAmount = item["toWinAmount"] except KeyError, e: toWinAmount = 0 if riskAmount: try: riskAmount = float(riskAmount) except Exception, e: print e riskAmount = riskAmount outstanding_bet_amount += riskAmount
def bulk_create_from_center_content(cls, center_content): bmatches = [] try: gamelines = search_dictionary_for_certain_keys("items", center_content)[0] #index 0 is gamelines index 1 is futures except (IndexError, TypeError): return [] try: matches = gamelines["itemList"]['items'] except (KeyError): return [] else: for match in matches: game_sport = "" game_id = None description = "" startTime = None competitors = [] home_team_abbreviation = "" home_team_short_name = "" home_team_full_name = "" away_team_full_name = "" away_team_short_name = "" away_team_abbreviation = "" game_link = "" outcome_objects_for_match = [] try: game_sport = match['sport'] except KeyError, e: pass try: game_id = int(match['id']) except KeyError, e: pass try: description = match['description'] except KeyError, e: pass
except KeyError, e: pass try: description = match["description"] except KeyError, e: pass try: startTime = match["startTime"] except KeyError, e: pass try: competitors = match["competitors"] except KeyError, e: pass try: home_team_abbreviation = search_dictionary_for_certain_keys("abbreviation", competitors[0]) except (KeyError, IndexError): pass try: home_team_short_name = search_dictionary_for_certain_keys("shortName", competitors[0]) except (KeyError, IndexError): pass try: home_team_full_name = search_dictionary_for_certain_keys("description", competitors[0]) except (KeyError, IndexError): pass try: away_team_short_name = search_dictionary_for_certain_keys("shortName", competitors[1]) except (KeyError, IndexError): pass try:
except KeyError, e: pass try: description = match['description'] except KeyError, e: pass try: startTime = match['startTime'] except KeyError, e: pass try: competitors = match['competitors'] except KeyError, e: pass try: home_team_abbreviation = search_dictionary_for_certain_keys("abbreviation", competitors[0]) except (KeyError, IndexError): pass try: home_team_short_name = search_dictionary_for_certain_keys("shortName", competitors[0]) except (KeyError, IndexError): pass try: home_team_full_name = search_dictionary_for_certain_keys("description", competitors[0]) except (KeyError, IndexError): pass try: away_team_short_name = search_dictionary_for_certain_keys("shortName", competitors[1]) except (KeyError, IndexError): pass try: