-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch_csc.py
39 lines (32 loc) · 1.1 KB
/
watch_csc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import constants
import time
import httplib2
from apiclient import discovery
from scripts.generate_email import get_data
import common.helpers as helpers
def main():
loop = True
while loop:
print("loop")
# Check the website for games
game_list = []
for team in constants.current_teams:
print("Getting data for {0}".format(team))
game_obj = get_data(team)
if game_obj:
game_list.append(game_obj)
# Make calendar events for new games
credentials = helpers.get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', http=http)
sports_cal = '65k8839pem89hd694b6l6damdk@group.calendar.google.com'
# parse into calendar event object
for game in game_list:
event = game.get_gcal_dict()
# upload event
response = service.events().insert(calendarId=sports_cal, body=event).execute()
loop = False
# # Slow down the loops
# time.sleep(10)
if __name__ == "__main__":
main()