Compare commits
15 Commits
101f9e84af
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 435535f7be | |||
| f526c93ccb | |||
| ba8410c0bf | |||
| f94ddb704a | |||
| 660a20901d | |||
| c776c42a0b | |||
| b4e2bea9f9 | |||
| fa4f7fa7d9 | |||
| c44c127ccf | |||
| 91410d41b4 | |||
| fdb6b32bdb | |||
| 29aef748d3 | |||
| d74939cc0e | |||
| e3338fc3f6 | |||
| e3e1425f5a |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@ __pycache__
|
||||
old
|
||||
Scripts
|
||||
pyvenv.cfg
|
||||
share
|
||||
*.swp
|
||||
|
||||
1
credentials.json
Normal file
1
credentials.json
Normal file
@@ -0,0 +1 @@
|
||||
{"installed":{"client_id":"639649814827-rt3k1lvdki8ijtf82lqo7v2e9lp2ekl5.apps.googleusercontent.com","project_id":"gmp-demo-project-996098018","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost"]}}
|
||||
1
credentials1.json
Normal file
1
credentials1.json
Normal file
@@ -0,0 +1 @@
|
||||
{"installed":{"client_id":"639649814827-6gkflt4og18ohg4lg6l93l1p8mguoi92.apps.googleusercontent.com","project_id":"gmp-demo-project-996098018","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost"]}}
|
||||
182
gcal.py
Normal file
182
gcal.py
Normal file
@@ -0,0 +1,182 @@
|
||||
import datetime
|
||||
import pytz
|
||||
import os.path
|
||||
|
||||
from google.auth.transport.requests import Request
|
||||
from google.oauth2.credentials import Credentials
|
||||
from google_auth_oauthlib.flow import InstalledAppFlow
|
||||
from googleapiclient.discovery import build
|
||||
from googleapiclient.errors import HttpError
|
||||
|
||||
# If modifying these scopes, delete the file token.json.
|
||||
SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]
|
||||
|
||||
|
||||
def main():
|
||||
"""Shows basic usage of the Google Calendar API.
|
||||
Prints the start and name of the next 10 events on the user's calendar.
|
||||
"""
|
||||
creds = None
|
||||
# The file token.json stores the user's access and refresh tokens, and is
|
||||
# created automatically when the authorization flow completes for the first
|
||||
# time.
|
||||
if os.path.exists("/home/tim/venv/ha_imagegen/token.json"):
|
||||
creds = Credentials.from_authorized_user_file("/home/tim/venv/ha_imagegen/token.json", SCOPES)
|
||||
# If there are no (valid) credentials available, let the user log in.
|
||||
if not creds or not creds.valid:
|
||||
if creds and creds.expired and creds.refresh_token:
|
||||
creds.refresh(Request())
|
||||
else:
|
||||
flow = InstalledAppFlow.from_client_secrets_file(
|
||||
"/home/tim/venv/ha_imagegen/credentials.json", SCOPES
|
||||
)
|
||||
creds = flow.run_local_server(port=0)
|
||||
# Save the credentials for the next run
|
||||
with open("/home/tim/venv/ha_imagegen/token.json", "w") as token:
|
||||
token.write(creds.to_json())
|
||||
|
||||
try:
|
||||
service = build("calendar", "v3", credentials=creds)
|
||||
|
||||
|
||||
calendars_to_use = [\
|
||||
# "meneelyl@gmail.com",\
|
||||
"Family",\
|
||||
"Tim Meneely2",\
|
||||
"meneelyt@gmail.com",\
|
||||
"1532 Ingomar Heights Road",\
|
||||
"Vivienne",\
|
||||
"Benjamin",\
|
||||
"Madeline",\
|
||||
"meneely.garcia@gmail.com"\
|
||||
]
|
||||
"""
|
||||
Pittsburgh Panthers football ncaaf_-m-02vklm3_%50ittsburgh+%50anthers+football#sports@group.v.calendar.google.com
|
||||
Penn State Nittany Lions football ncaaf_-m-0frm7n_%50enn+%53tate+%4eittany+%4cions+football#sports@group.v.calendar.google.com
|
||||
Pittsburgh Steelers nfl_-m-05tfm_%50ittsburgh+%53teelers#sports@group.v.calendar.google.com
|
||||
Dallas Cowboys nfl_-m-02896_%44allas+%43owboys#sports@group.v.calendar.google.com
|
||||
Pittsburgh Penguins nhl_-m-0hn6d_%50ittsburgh+%50enguins#sports@group.v.calendar.google.com
|
||||
Holidays in United States en.usa#holiday@group.v.calendar.google.com
|
||||
meneelyl@gmail.com meneelyl@gmail.com
|
||||
Family family14345103599446093558@group.calendar.google.com
|
||||
Meneely Birthdays fjlvq3dnhfvn76ihljocbrhrdc@group.calendar.google.com
|
||||
Tim Meneely2 k7iohvqfspej540e37bqr1hkso@group.calendar.google.com
|
||||
1532 Ingomar Heights Road 3a0104e2f97668033b30227726b79f48b9f341a84cd9fa57aa4e23851aee1750@group.calendar.google.com
|
||||
Vivienne fb53f1ba30abe33a395cb3483aaba416675e2ac829e9e74ca25c10d4fae593c5@group.calendar.google.com
|
||||
Benjamin ed47cdac4f626432af8c0d1956499d258d0365cf3fe6ee70ce73d7d478b0f1dd@group.calendar.google.com
|
||||
Madeline c6eed2e9ec829d835357032a344d2f6894677a6e652d04345c73249cd9bff8fb@group.calendar.google.com
|
||||
meneelyt@gmail.com meneelyt@gmail.com
|
||||
meneely.garcia@gmail.com meneely.garcia@gmail.com
|
||||
"""
|
||||
|
||||
calendarids = []
|
||||
calendarsummaries = []
|
||||
calendar_list = (service.calendarList().list()).execute().get("items", [])
|
||||
for result in calendar_list:
|
||||
if result.get("summary",[]) in calendars_to_use:
|
||||
calendarids.append(result.get("id",[]))
|
||||
calendarsummaries.append(result.get("summary",[]))
|
||||
#print("result",result.get("summary",[]),result.get("id",[]))
|
||||
# print("summaries",calendarsummaries)
|
||||
#print("first result",calendar_list[0])
|
||||
#print("first result",calendar_list[len(calendar_list)-1])
|
||||
#result meneelyl@gmail.com meneelyl@gmail.com
|
||||
#result Family family14345103599446093558@group.calendar.google.com
|
||||
#result Meneely Birthdays fjlvq3dnhfvn76ihljocbrhrdc@group.calendar.google.com
|
||||
#result Tim Meneely2 k7iohvqfspej540e37bqr1hkso@group.calendar.google.com
|
||||
#result meneelyt@gmail.com meneelyt@gmail.com
|
||||
#result 1532 Ingomar Heights Road 3a0104e2f97668033b30227726b79f48b9f341a84cd9fa57aa4e23851aee1750@group.calendar.google.com
|
||||
#result Vivienne fb53f1ba30abe33a395cb3483aaba416675e2ac829e9e74ca25c10d4fae593c5@group.calendar.google.com
|
||||
#result Benjamin ed47cdac4f626432af8c0d1956499d258d0365cf3fe6ee70ce73d7d478b0f1dd@group.calendar.google.com
|
||||
#result Madeline c6eed2e9ec829d835357032a344d2f6894677a6e652d04345c73249cd9bff8fb@group.calendar.google.com
|
||||
|
||||
|
||||
|
||||
# Call the Calendar API
|
||||
now = datetime.datetime.now(tz=datetime.timezone.utc).isoformat()
|
||||
tomorrow = (datetime.datetime.now(tz=datetime.timezone.utc)+datetime.timedelta(days=3)).isoformat()
|
||||
#print("Getting the upcoming 10 events")
|
||||
allevents = []
|
||||
for i in range(0,len(calendarids)):
|
||||
events_result = (
|
||||
service.events()
|
||||
.list(
|
||||
calendarId=calendarids[i],
|
||||
timeMin=now,
|
||||
timeMax=tomorrow,
|
||||
maxResults=10,
|
||||
singleEvents=True,
|
||||
orderBy="startTime",
|
||||
)
|
||||
.execute()
|
||||
)
|
||||
events = events_result.get("items", [])
|
||||
|
||||
#if not events:
|
||||
# print("No upcoming events found.")
|
||||
# return
|
||||
|
||||
# Prints the start and name of the next 10 events
|
||||
#for event in events:
|
||||
# start = event["start"].get("dateTime", event["start"].get("date"))
|
||||
#print(start, event["summary"],"(from "+calendarsummaries[i]+")")
|
||||
#print("type events",type(events),"type event",type(event))
|
||||
#allevents.append(events)
|
||||
useastern_timezone = pytz.timezone("US/Eastern")
|
||||
today = datetime.datetime.now(tz=useastern_timezone).date() # #.strftime("%Y-%m-%d")
|
||||
for event in events:
|
||||
if event.get("summary","Private") not in ["Middle","Private"]:
|
||||
event["calendarname"]=calendarsummaries[i]
|
||||
if "dateTime" in event["start"]:
|
||||
#startdate = event["start"].get("dateTime")
|
||||
eventdate = datetime.datetime.strptime(event["start"]["dateTime"],"%Y-%m-%dT%H:%M:%S%z")
|
||||
#print("uses dateTime",event["summary"],eventdate)
|
||||
elif "date" in event["start"]:
|
||||
#startdate = event["start"].get("date")
|
||||
eventdate = datetime.datetime.strptime(event["start"]["date"],"%Y-%m-%d")
|
||||
else:
|
||||
eventdate = None
|
||||
#print("eventdate",eventdate,type(eventdate))
|
||||
#startdate = event["start"],event["start"].get("dateTime",event["start"].get("date"))
|
||||
#print("startdate",startdate,type(startdate))
|
||||
|
||||
#eventdate = datetime.datetime.strptime(event["start"]["dateTime"],"%Y-%m-%dT%H:%M:%S%z")
|
||||
if "dateTime" in event["start"]:
|
||||
prettytime = (" "+eventdate.strftime("%I:%M %p")).replace(" 0"," ")
|
||||
else:
|
||||
prettytime = "" #All day"
|
||||
#if datetime.datetime.now().date() == eventdate.date():
|
||||
if today == eventdate.date():
|
||||
pass # This is today, print as is
|
||||
else:
|
||||
prettytime = eventdate.strftime("%a")+prettytime
|
||||
event["prettytime"] = prettytime.strip() #(" "+eventdate.strftime("%I:%M %p")).replace(" 0"," ")
|
||||
#if event["summary"] == "Girls":
|
||||
# print("event",event)
|
||||
allevents.append(event)
|
||||
#print("allevents",allevents)
|
||||
allevents2 = sorted(allevents, key=lambda event: event["start"].get("dateTime", event["start"].get("date")))
|
||||
#for event in allevents2:
|
||||
# start = event["start"].get("dateTime", event["start"].get("date"))
|
||||
# print(start, event["summary"],"(from "+calendarsummaries[event["mycalendarkey"]]+")")
|
||||
except HttpError as error:
|
||||
print(f"An error occurred: {error}")
|
||||
allevents2 = []
|
||||
return allevents2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
allevents = (main())
|
||||
for event in allevents:
|
||||
#start = event["start"].get("dateTime", event["start"].get("date"))
|
||||
#print(start, event["summary"],"(from "+event["calendarname"]+")")
|
||||
print(event["prettytime"], event.get("summary","No summary"),"(from "+event["calendarname"]+")")
|
||||
if event.get("summary","No summary") == "No summary":
|
||||
print("Rogue event",event)
|
||||
#print(event["start"],type(event["start"]))
|
||||
#eventdate = datetime.datetime.strptime(event["start"]["dateTime"],"%Y-%m-%dT%H:%M:%S%z")
|
||||
#print((" "+eventdate.strftime("%I:%M %p")).replace(" 0"," "))
|
||||
#print(eventdate,type(eventdate))
|
||||
#s=datetime.datetime.strptime(,"%Y-%m-%dT%H:%M:%S%z")
|
||||
#print((event["start"]["dateTime"])) #.datetime.datetime.strftime("%I:%M %p"))
|
||||
#print("event",allevents[0])
|
||||
49
gcal_list.py
Normal file
49
gcal_list.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import datetime
|
||||
import os.path
|
||||
|
||||
from google.auth.transport.requests import Request
|
||||
from google.oauth2.credentials import Credentials
|
||||
from google_auth_oauthlib.flow import InstalledAppFlow
|
||||
from googleapiclient.discovery import build
|
||||
from googleapiclient.errors import HttpError
|
||||
|
||||
# If modifying these scopes, delete the file token.json.
|
||||
SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]
|
||||
|
||||
|
||||
def main():
|
||||
"""Shows basic usage of the Google Calendar API.
|
||||
Prints the start and name of the next 10 events on the user's calendar.
|
||||
"""
|
||||
creds = None
|
||||
# The file token.json stores the user's access and refresh tokens, and is
|
||||
# created automatically when the authorization flow completes for the first
|
||||
# time.
|
||||
if os.path.exists("token.json"):
|
||||
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
|
||||
# If there are no (valid) credentials available, let the user log in.
|
||||
if not creds or not creds.valid:
|
||||
if creds and creds.expired and creds.refresh_token:
|
||||
creds.refresh(Request())
|
||||
else:
|
||||
flow = InstalledAppFlow.from_client_secrets_file(
|
||||
"credentials.json", SCOPES
|
||||
)
|
||||
creds = flow.run_local_server(port=0)
|
||||
# Save the credentials for the next run
|
||||
with open("token.json", "w") as token:
|
||||
token.write(creds.to_json())
|
||||
|
||||
try:
|
||||
service = build("calendar", "v3", credentials=creds)
|
||||
|
||||
calendar_list = (service.calendarList().list()).execute().get("items", [])
|
||||
for result in calendar_list:
|
||||
print(result.get("summary",[]),result.get("id",[]))
|
||||
except HttpError as error:
|
||||
print(f"An error occurred: {error}")
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
allevents = (main())
|
||||
5
google_calendar_oath.txt
Normal file
5
google_calendar_oath.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Client ID
|
||||
639649814827-6gkflt4og18ohg4lg6l93l1p8mguoi92.apps.googleusercontent.com
|
||||
|
||||
Client secret
|
||||
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
|
||||
@@ -23,7 +23,7 @@ def get_current_weather(api_key, lat, lng, units="IMPERIAL"):
|
||||
return response.json()
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
#print(f"An error occurred: {e}")
|
||||
print(f"Current weather: An error occurred: {e}")
|
||||
return None
|
||||
|
||||
def get_daily_forecast(api_key, lat, lng, days=2):
|
||||
@@ -51,7 +51,7 @@ def get_daily_forecast(api_key, lat, lng, days=2):
|
||||
return data
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
#print(f"An error occurred: {e}")
|
||||
print(f"Forecast: An error occurred: {e}")
|
||||
return None
|
||||
|
||||
def get_google_weather():
|
||||
@@ -70,7 +70,7 @@ def get_google_weather():
|
||||
humidity = current_data.get("relativeHumidity")
|
||||
|
||||
theweather["current"] = (f"{condition}") + (f", {temp.get('degrees')}°F")\
|
||||
+ (f", {humidity}%") + (f" hum., Feels like: {feels_like.get('degrees')}°F")
|
||||
+ (f", {humidity}%") + (f" hum., Feels like: {int(feels_like.get('degrees'))}°F")
|
||||
else: # current_data not returned
|
||||
theweather["current"] = "Problem retrieving current weather"
|
||||
|
||||
@@ -81,12 +81,12 @@ def get_google_weather():
|
||||
max_temp = day.get("maxTemperature", {}).get("degrees")
|
||||
min_temp = day.get("minTemperature", {}).get("degrees")
|
||||
condition = day.get("daytimeForecast", {}).get("weatherCondition", {}).get("description", {}).get("text")
|
||||
theweather["forecast_today"] = (f"{condition}") + (f", {min_temp}°F-{max_temp}°F")
|
||||
theweather["forecast_today"] = (f"{condition}") + (f", {int(min_temp)}°F-{int(max_temp)}°F")
|
||||
day = forecast_data.get("forecastDays", [])[1]
|
||||
max_temp = day.get("maxTemperature", {}).get("degrees")
|
||||
min_temp = day.get("minTemperature", {}).get("degrees")
|
||||
condition = day.get("daytimeForecast", {}).get("weatherCondition", {}).get("description", {}).get("text")
|
||||
theweather["forecast_tomorrow"] = (f"{condition}") + (f", {min_temp}°F-{max_temp}°F")
|
||||
theweather["forecast_tomorrow"] = (f"{condition}") + (f", {int(min_temp)}°F-{int(max_temp)}°F")
|
||||
else:
|
||||
theweather["forecast_tomorrow"] = "Problem retrieving weather forecast"
|
||||
|
||||
|
||||
63
imagegen.py
63
imagegen.py
@@ -1,37 +1,45 @@
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import datetime
|
||||
import pytz
|
||||
#import asyncio
|
||||
import google_weather
|
||||
import mlb
|
||||
#from getweather impor]t getweather
|
||||
import gcal
|
||||
|
||||
fontBaseHeight = 25
|
||||
fnt = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",fontBaseHeight)
|
||||
fntSmall = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",fontBaseHeight-10)
|
||||
fntBold = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",fontBaseHeight)
|
||||
fntBigBold = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",fontBaseHeight+5)
|
||||
|
||||
def WriteTextBlock(text, context, font = fnt, column=0, row=0, anchor = "la"):
|
||||
context.multiline_text((column, row), text, font=font, fill=0, anchor = anchor)
|
||||
boundingBox = context.multiline_textbbox((column,row),text,font=font,anchor=anchor)
|
||||
return boundingBox[3]
|
||||
|
||||
# create an image
|
||||
displaysize = [800,480] # width, height - same as text writing features
|
||||
row = 0 # current row to write at
|
||||
out = Image.new("L", (displaysize[0], displaysize[1]),255)
|
||||
|
||||
# get a font
|
||||
fnt = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",25)
|
||||
fntBold = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",35)
|
||||
HeightNormal = 25
|
||||
HeightBold = 35
|
||||
#HeightNormal = 25
|
||||
#HeightBold = 35
|
||||
MarginLeft = 1
|
||||
MarginIndent = 5
|
||||
MarginIndent = 10
|
||||
# get a drawing context
|
||||
d = ImageDraw.Draw(out)
|
||||
|
||||
# create text
|
||||
txt1a = "As of "+datetime.datetime.now(pytz.timezone('America/New_York')).strftime('%I:%M %p')
|
||||
#row = WriteTextBlock(txt1a,d,fnt,displaysize[0]/2,row,"ma")
|
||||
rowThrowAway = WriteTextBlock(txt1a,d,fntSmall,displaysize[0],row,"ra")
|
||||
|
||||
txt1 = datetime.datetime.now(pytz.timezone('America/New_York')).strftime('%A %B %d, %Y')
|
||||
# draw multiline text
|
||||
d.multiline_text((displaysize[0]/2, row), txt1, font=fntBold, fill=0, anchor = "ma") #, align="center")
|
||||
row += HeightBold
|
||||
row = WriteTextBlock(txt1,d,fntBigBold,displaysize[0]/2,row,"ma")
|
||||
|
||||
txt1a = "As of "+datetime.datetime.now(pytz.timezone('America/New_York')).strftime('%I:%M %p')
|
||||
d.multiline_text((displaysize[0]/2, row), txt1a, font=fnt, fill=0, anchor = "ma") #, align="center")
|
||||
row += HeightNormal
|
||||
|
||||
d.multiline_text((MarginLeft, row), "Weather:", font=fnt, fill=0, anchor = "la")
|
||||
row += HeightNormal
|
||||
row = WriteTextBlock("Weather",d,fntBold,MarginLeft,row,"la")
|
||||
try:
|
||||
weather = google_weather.get_google_weather()
|
||||
txt2 = "Current: "+weather["current"] \
|
||||
@@ -39,14 +47,25 @@ try:
|
||||
+"\nTomorrow: "+weather["forecast_tomorrow"]
|
||||
except: # Assume the weather API blew up
|
||||
txt2 = "Problem getting weather (from ImageGen)"
|
||||
d.multiline_text((MarginIndent, row), txt2, font=fnt, fill=0, anchor = "la")
|
||||
row += 3*HeightNormal
|
||||
row = WriteTextBlock(txt2,d,fnt,MarginIndent,row,"la")
|
||||
|
||||
d.multiline_text((MarginLeft,row), "Pirates:", font=fnt, fill=0, anchor = "la")
|
||||
row += HeightNormal
|
||||
d.multiline_text((MarginIndent,row), mlb.get_pirates(), font=fnt, fill=0, anchor = "la")
|
||||
row += 3*HeightNormal
|
||||
row = WriteTextBlock("Pirates",d,fntBold,MarginLeft,row,"la")
|
||||
row = WriteTextBlock(mlb.get_pirates(),d,fnt,MarginIndent,row,"la")
|
||||
|
||||
appointments = gcal.main()
|
||||
apptxt = ""
|
||||
for event in appointments:
|
||||
#start = event["start"].get("dateTime", event["start"].get("date"))
|
||||
#apptxt+= start+": "+event["summary"]+" (from "+event["calendarname"]+")\n"
|
||||
if event["prettytime"]:
|
||||
apptxt+= event["prettytime"]+": "+event["summary"]+" (from "+event["calendarname"]+")\n"
|
||||
else:
|
||||
apptxt+= event["summary"]+" (from "+event["calendarname"]+")\n"
|
||||
|
||||
row = WriteTextBlock("Appointments",d,fntBold,MarginLeft,row,"la")
|
||||
row = WriteTextBlock(apptxt,d,fnt,MarginIndent,row,"la")
|
||||
|
||||
|
||||
row = WriteTextBlock("========== End =========",d,fnt,MarginLeft,row,"la")
|
||||
|
||||
out.save("/mnt/nfs/HomeAutomation/ForHA.jpg","JPEG")
|
||||
#out.show()
|
||||
|
||||
|
||||
11
mlb.py
11
mlb.py
@@ -21,13 +21,15 @@ def process_game(game,mytz):
|
||||
else: # game in progress
|
||||
if score_pirates > score_other:
|
||||
results += ", Pirates winning"
|
||||
else:
|
||||
elif score_pirates < score_other:
|
||||
results += ", Pirates losing"
|
||||
else:
|
||||
results += ", tied"
|
||||
results += " "+str(game["away_score"])+" - "+str(game["home_score"])
|
||||
if game["status"] != "Final":
|
||||
gamedate = datetime.datetime.strptime(game["game_datetime"],"%Y-%m-%dT%H:%M:%SZ")
|
||||
gamedateutc = gamedate.replace(tzinfo=datetime.timezone.utc)
|
||||
results+= " "+gamedateutc.astimezone(tz=mytz).strftime("%I:%M %p")
|
||||
results+= (" "+gamedateutc.astimezone(tz=mytz).strftime("%I:%M %p")).replace(" 0"," ")
|
||||
if game["national_broadcasts"]:
|
||||
nb = ""
|
||||
for b in game["national_broadcasts"]:
|
||||
@@ -45,7 +47,12 @@ def get_pirates():
|
||||
todaystr = datetime.datetime.now(tz=useastern_timezone).strftime("%Y-%m-%d")
|
||||
tomorrow = datetime.datetime.now(tz=useastern_timezone)+datetime.timedelta(days=1)
|
||||
tomorrowstr = tomorrow.strftime("%Y-%m-%d")
|
||||
yesterday = datetime.datetime.now(tz=useastern_timezone)+datetime.timedelta(days=-1)
|
||||
yesterdaystr = yesterday.strftime("%Y-%m-%d")
|
||||
piratesid = statsapi.lookup_team('pittsburgh')[0]['id']
|
||||
yesterdaysgame = statsapi.schedule(team=piratesid,date=yesterdaystr)
|
||||
if yesterdaysgame:
|
||||
results+= "Yesterday: "+process_game(yesterdaysgame[0],useastern_timezone)+"\n"
|
||||
todaysgame = statsapi.schedule(team=piratesid,date=todaystr)
|
||||
if todaysgame:
|
||||
results+= "Today: "+process_game(todaysgame[0],useastern_timezone)+"\n"
|
||||
|
||||
@@ -2,3 +2,6 @@ mlb-statsapi==1.9.0
|
||||
pillow==12.2.0
|
||||
pytz==2026.2
|
||||
requests==2.34.2
|
||||
google-api-python-client
|
||||
google-auth-httplib2
|
||||
google-auth-oauthlib
|
||||
|
||||
1
token.json
Normal file
1
token.json
Normal file
@@ -0,0 +1 @@
|
||||
{"token": "ya29.a0AQvPyIMP600wh7gMW2d7H3QUZJASVBf5iAK2K-hT59qwZ5C24Q6kW9jElF1vXW-AQOQu0xabV6clQfbvxlXhuHbqlQXZ9eV06IS1lBmQ_NTSG6SOgp2j8V3JV0gHbLYcCsibeD4_hwrXslXEOLSQYmlJkQYD0N8D7PxCnOuJX1JubffTlCQ57z9k2NjJ4KgD9M6D281saCgYKAUMSARMSFQHGX2MiBC1fCe8w0mGVcsXLgtRZQA0207", "refresh_token": "1//05gtSbVRZIG0QCgYIARAAGAUSNwF-L9Irsu_pTbTjO_hMIFTJier0k5qwNj703kl1Uzw6bSK9GN9uK8taw1rNofOxQBXJPZJg6_Y", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "639649814827-rt3k1lvdki8ijtf82lqo7v2e9lp2ekl5.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/calendar.readonly"], "universe_domain": "googleapis.com", "account": "", "expiry": "2026-06-02T01:00:01.538193Z"}
|
||||
Reference in New Issue
Block a user