cryobry 4 years ago
parent
commit
04536cd5ad
1 changed files with 14 additions and 5 deletions
  1. 14 5
      nba_playoffs_game_updater.py

+ 14 - 5
nba_playoffs_game_updater.py

@@ -13,7 +13,6 @@ import timeout_decorator
 
 _spreadsheetKey = "12Zv95ZMJ008KXC5ytVnBusjX9wUnpOg0TOLwmxMNOTQ"
 
-####### GET SHEETS AND NUM PARTICIPANTS #######
 
 def _getStatsSheet(_key):
   scope = ['https://spreadsheets.google.com/feeds',
@@ -33,14 +32,22 @@ def _getStatsSheet(_key):
   # count participants
   _numParticipants = _leaderSheet.row_count - 1
 
-  return _statsSheet, _numParticipants
+  return _statsSheet, _leaderSheet
   
+  
+def _getNumParticipants(_leaderSheet):
 
-def _getRowsFromDate(_statsSheet, _numParticipants):
+  _numParticipants = _leaderSheet.row_count - 1
+  
+  return _numParticipants
   
+
+def _getRowsFromDate(_statsSheet, _numParticipants):
+
   # get today
   _today = datetime.date.today()
-  #_today = datetime.date(2018, 5, 2)
+  # else manually set the date
+  #_today = datetime.date(2018, 5, 16)
   
   _urlDate = _today.strftime('%m/%d/%Y')
 
@@ -88,6 +95,7 @@ def _getPlayerFirstNameLastName(_player):
   _firstName = _firstNamelastName[0]
   _firstName = _firstName.replace('.', '')
   _lastName = _firstNamelastName[1]
+  
   return _firstName, _lastName
   
 
@@ -144,7 +152,8 @@ def _badName(_statsSheet, _playerCell):
 while True:
 
   try:
-    _statsSheet, _numParticipants = _getStatsSheet(_spreadsheetKey)
+    _statsSheet, _leaderSheet = _getStatsSheet(_spreadsheetKey)
+    _numParticipants = _getNumParticipants(_leaderSheet)
     _startRow, _lastRow, _urlDate = _getRowsFromDate(_statsSheet, _numParticipants)
     if _startRow == 0:
       print("No games today! Pausing for 1000s")