Created
September 2, 2016 17:41
-
-
Save allisontharp/022e1f5a2ecde8d3661133817deeb0d3 to your computer and use it in GitHub Desktop.
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
import nflgame as n | |
import time, smtplib | |
def send(SUBJECT, TEXT): | |
gmail_user = 'you@emailaddress.com' | |
gmail_pwd = 'YourVerySecurePassword' | |
server = smtplib.SMTP("smtp.gmail.com", 587) | |
server.ehlo() | |
server.starttls() | |
server.login(gmail_user, gmail_pwd) | |
FROM = 'This@email.com' | |
TO = ['one@email.com','two@email.com'] | |
message = """\ | |
From: %s | |
To: %s | |
Subject: %s | |
\n | |
%s | |
""" % (FROM, ", ".join(TO), SUBJECT, TEXT) | |
# Send the mail | |
print message | |
server.sendmail(FROM, TO, message) | |
server.quit() | |
# | |
g = n.one(2016, 4, 'CIN', 'IND', kind='PRE') | |
scores0 = len(g.scores) | |
hometo0 = g.stats_home[6] | |
awayto0 = g.stats_away[6] | |
awaypenalty0 = g.stats_away[4] | |
homepenalty0 = g.stats_home[4] | |
awaypenyds0 = g.stats_away[5] | |
homepenyds0 = g.stats_home[5] | |
while(not(g.game_over())): | |
g = n.one(2016, 4, 'CIN', 'IND', kind='PRE') | |
games = n.games(year=2016, week=4, kind='PRE', away='IND') | |
scores = g.scores | |
hometo = g.stats_home[6] | |
awayto = g.stats_away[6] | |
awaypenalty = g.stats_away[4] | |
homepenalty = g.stats_home[4] | |
awaypenyds = g.stats_away[5] | |
homepenyds = g.stats_home[5] | |
if len(scores) > scores0: # someone scored | |
text = str(scores[len(scores)-1]) + ' ' + str(g.nice_score()) | |
send('Scoring Play', text) | |
print text | |
scores0 += 1 | |
if hometo > hometo0: | |
send('Home Turnover', str(hometo)) | |
print "Home turnover number: " + str(hometo) | |
hometo0 = hometo | |
if awayto > awayto0: | |
send('Away Turnover', str(awayto)) | |
print "Away turnover number: " + str(awayto) | |
awayto0 = awayto | |
if awaypenalty > awaypenalty0: | |
send('Away Penalty', str(awaypenyds - awaypenyds0)) | |
print "Away penalty for " + str(awaypenyds - awaypenyds0) + " yards." | |
awaypenalty0 = awaypenalty | |
awaypenyds0 = awaypenyds | |
if homepenalty > homepenalty0: | |
send("Home Penalty", str(homepenyds - homepenyds0)) | |
print 'Home penalty for ' + str(homepenyds - homepenyds0) + ' yards.' | |
homepenalty0 = homepenalty | |
homepenyds0 = homepenyds | |
time.sleep(120) | |
send('Final Score', g.nice_score().encode('utf-8')) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment