From 29aef748d3a03835dd3e3993828511e635b52f08 Mon Sep 17 00:00:00 2001 From: Tim Meneely Date: Tue, 26 May 2026 22:17:12 +0000 Subject: [PATCH] Tweaking Pirate time to suppress 0, starting gcal --- ...2e9lp2ekl5.apps.googleusercontent.com.json | 1 + credentials.json | 1 + credentials1.json | 1 + gcal_quickstart.py | 70 +++++++++++++++++++ google_calendar_oath.txt | 5 ++ mlb.py | 2 +- requirements.txt | 3 + token.json | 1 + 8 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 client_secret_639649814827-rt3k1lvdki8ijtf82lqo7v2e9lp2ekl5.apps.googleusercontent.com.json create mode 100644 credentials.json create mode 100644 credentials1.json create mode 100644 gcal_quickstart.py create mode 100644 google_calendar_oath.txt create mode 100644 token.json diff --git a/client_secret_639649814827-rt3k1lvdki8ijtf82lqo7v2e9lp2ekl5.apps.googleusercontent.com.json b/client_secret_639649814827-rt3k1lvdki8ijtf82lqo7v2e9lp2ekl5.apps.googleusercontent.com.json new file mode 100644 index 0000000..a14cf47 --- /dev/null +++ b/client_secret_639649814827-rt3k1lvdki8ijtf82lqo7v2e9lp2ekl5.apps.googleusercontent.com.json @@ -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"]}} \ No newline at end of file diff --git a/credentials.json b/credentials.json new file mode 100644 index 0000000..a14cf47 --- /dev/null +++ b/credentials.json @@ -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"]}} \ No newline at end of file diff --git a/credentials1.json b/credentials1.json new file mode 100644 index 0000000..446178b --- /dev/null +++ b/credentials1.json @@ -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"]}} \ No newline at end of file diff --git a/gcal_quickstart.py b/gcal_quickstart.py new file mode 100644 index 0000000..7c56438 --- /dev/null +++ b/gcal_quickstart.py @@ -0,0 +1,70 @@ +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) + + # Call the Calendar API + now = datetime.datetime.now(tz=datetime.timezone.utc).isoformat() + print("Getting the upcoming 10 events") + events_result = ( + service.events() + .list( + calendarId="primary", + timeMin=now, + 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"]) + + except HttpError as error: + print(f"An error occurred: {error}") + + +if __name__ == "__main__": + main() diff --git a/google_calendar_oath.txt b/google_calendar_oath.txt new file mode 100644 index 0000000..849dbdf --- /dev/null +++ b/google_calendar_oath.txt @@ -0,0 +1,5 @@ +Client ID +639649814827-6gkflt4og18ohg4lg6l93l1p8mguoi92.apps.googleusercontent.com + +Client secret +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 diff --git a/mlb.py b/mlb.py index 160d29f..75bab04 100644 --- a/mlb.py +++ b/mlb.py @@ -29,7 +29,7 @@ def process_game(game,mytz): 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"]: diff --git a/requirements.txt b/requirements.txt index 47b7b96..b58e841 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/token.json b/token.json new file mode 100644 index 0000000..6829f18 --- /dev/null +++ b/token.json @@ -0,0 +1 @@ +{"token": "ya29.a0AQvPyINS2iZNfJ519Nr-wHpTMBFKGLppSj2Lk89O4cU3BiY4zYTs7HmNzD6tnTUuR4u70pIP1PDRfaabCf-GRZiZZM0G4Wjt54yJGvTTrtsR6gUzfDcMEVscBU-pM4tJ8QqqtloKR05ZwT98IPxbTKXnD-xWY3Q1efRoUXWfwrXPXFNOOgdfZG3RntyO-9j271Z88xsaCgYKAWkSARMSFQHGX2Mi1NaInHzn-a98xKl5luLdiQ0206", "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-05-26T22:47:19Z"} \ No newline at end of file