Tweaking Pirate time to suppress 0, starting gcal
This commit is contained in:
@@ -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
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"]}}
|
||||
70
gcal_quickstart.py
Normal file
70
gcal_quickstart.py
Normal file
@@ -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()
|
||||
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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
|
||||
2
mlb.py
2
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"]:
|
||||
|
||||
@@ -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.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"}
|
||||
Reference in New Issue
Block a user