diff --git a/gcalcli/gcal.py b/gcalcli/gcal.py index 09a3c42..827c142 100644 --- a/gcalcli/gcal.py +++ b/gcalcli/gcal.py @@ -1025,8 +1025,18 @@ def _iterate_events(self, start_datetime, event_list, year_date=False, return selected - def _GetAllEvents(self, cal, events, end): - + def _GetAllEvents(self, cal, start, end, search_text): + events = self._retry_with_backoff( + self.get_events() + .list( + calendarId=cal['id'], + timeMin=start.isoformat() if start else None, + timeMax=end.isoformat() if end else None, + q=search_text if search_text else None, + singleEvents=True + ) + ) + event_list = [] while 1: @@ -1078,6 +1088,10 @@ def _GetAllEvents(self, cal, events, end): self.get_events() .list( calendarId=cal['id'], + timeMin=start.isoformat() if start else None, + timeMax=end.isoformat() if end else None, + q=search_text if search_text else None, + singleEvents=True, pageToken=pageToken ) ) @@ -1090,17 +1104,7 @@ def _search_for_events(self, start, end, search_text): event_list = [] for cal in self.cals: - events = self._retry_with_backoff( - self.get_events() - .list( - calendarId=cal['id'], - timeMin=start.isoformat() if start else None, - timeMax=end.isoformat() if end else None, - q=search_text if search_text else None, - singleEvents=True - ) - ) - event_list.extend(self._GetAllEvents(cal, events, end)) + event_list.extend(self._GetAllEvents(cal, start, end, search_text)) event_list.sort(key=lambda x: x['s'])