This file contains hidden or 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
| def get_balance(base_url, username, password): | |
| url = base_url + "/v1/client/balance" | |
| b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
| headers = {'Content-length' : '0', | |
| 'Content-type' : 'application/json', | |
| 'Authorization' : "Basic " + b64str.decode('utf-8')} | |
| req = ulib.Request(url, headers=headers) | |
| responseData = ulib.urlopen(req).read() | |
| balance = json.loads(responseData.decode('utf-8')) |
This file contains hidden or 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
| def get_sport_odds(base_url, username, password, sport = '15'): | |
| url = base_url + '/v1/odds?sportId=' + str(sport) + '&oddsFormat=DECIMAL' | |
| b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
| headers = {'Content-length' : '0', | |
| 'Content-type' : 'application/json', | |
| 'Authorization' : "Basic " + b64str.decode('utf-8') | |
| } | |
| req = ulib.Request(url, headers=headers) | |
| responseData = ulib.urlopen(req).read() |
This file contains hidden or 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
| def find_bet(all_odds): | |
| bet_info = {} | |
| favourable_odds = 1.91 | |
| bet_info['sportId'] = all_odds['sportId'] | |
| for i in all_odds['leagues']: | |
| bet_info['leagueId'] = i['id'] | |
| for j in i['events']: | |
| bet_info['eventId'] = j['id'] | |
| for k in j['periods']: | |
| bet_info['period'] = k['number'] |
This file contains hidden or 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
| def get_bet_info(base_url, username, password, bet, favourable_odds = 1.91): | |
| b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
| headers = {'Content-length' : '0', | |
| 'Content-type' : 'application/json', | |
| 'Authorization' : "Basic " + b64str.decode('utf-8')} | |
| url_without_team = base_url + "/v1/line?sportId={0}&leagueId={1}&eventId={2}&periodNumber={3}&betType=MONEYLINE&OddsFormat=DECIMAL"\ | |
| .format(bet['sportId'], bet['leagueId'], bet['eventId'],bet['period']) | |
| url = url_without_team + "&Team=Team1" |
This file contains hidden or 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
| def place_bet(base_url, username, password, bet, stake): | |
| url = base_url + "/v1/bets/place" | |
| b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
| headers = {'Content-length' : '1', | |
| 'Content-type' : 'application/json', | |
| 'Authorization' : "Basic " + b64str.decode('utf-8')} | |
| data = { | |
| "uniqueRequestId":uuid.uuid4().hex, |
This file contains hidden or 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
| if __name__ == "__main__": | |
| base_url = "https://api.pinnaclesports.com" | |
| username = <username> | |
| password = <password> | |
| stake = 1.5 | |
| balance = get_balance(base_url, username, password) | |
| odds = get_sport_odds(base_url, username, password) | |
| bet = find_bet(odds) |
This file contains hidden or 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
| import tweepy | |
| consumer_key = 'consumer_key' | |
| consumer_secret = 'consumer_secret' | |
| access_key = 'access_key' | |
| access_secret = 'access_secret' | |
| def authorize_account(consumer_key = consumer_key, consumer_secret = consumer_secret, | |
| access_key = access_key, access_secret = access_secret): | |
| auth = tweepy.OAuthHandler(consumer_key, consumer_secret) |
This file contains hidden or 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
| def read_messages(twitter_account, since = 0): | |
| mentions = tweepy.Cursor(twitter_account.mentions_timeline, since_id = str(since)).items() | |
| tweets = [] | |
| for tweet in tweets: | |
| tweets.append(tweet.text) | |
| if (tweet.id > since): | |
| since = tweet.id | |
| return {"messages":tweets, "since_id": since} |
This file contains hidden or 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
| def get_reddit_agent(user_agent, client_id, client_secret, redirect='http://127.0.0.1'): | |
| reddit_agent = praw.Reddit(user_agent = user_agent) | |
| reddit_agent.set_oauth_app_info(client_id = client_id, | |
| client_secret = client_secret, | |
| redirect_uri = redirect) | |
| return reddit_agent |
This file contains hidden or 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
| def get_subreddit_comments(reddit_agent, subreddit, comments_out = [], count = 100): | |
| #surrounded by try catch in case API calls get exceed | |
| try: | |
| sub = reddit_agent.get_subreddit(subreddit) | |
| comments_raw = sub.get_comments(sub, limit=count) | |
| comments_flat = praw.helpers.flatten_tree(comments_raw) | |
| for comment in comments_flat: | |
| #try catch handles end of reply tree containing a null comment | |
| try: | |
| if hasattr(comment, 'comments'): |
OlderNewer