Skip to content

Commit

Permalink
Add token to all event requests
Browse files Browse the repository at this point in the history
  • Loading branch information
hancush committed Nov 29, 2023
1 parent 4306efb commit 9c0ddd1
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions lametro/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class LametroEventScraper(LegistarAPIEventScraper, Scraper):
EVENTSPAGE = "https://metro.legistar.com/Calendar.aspx"
TIMEZONE = "America/Los_Angeles"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

if TOKEN:
self.params = {"token": TOKEN}

def _pair_events(self, events):
paired_events = []
unpaired_events = {}
Expand Down Expand Up @@ -87,22 +93,6 @@ def _find_partner(self, event):

return None

def search(self, route, item_key, search_conditions):
search_url = self.BASE_URL + route

params = {"$filter": search_conditions}

# Add token to requests to the events endpoint, so we can capture SAP events.
if route == "/events/" and TOKEN:
params["token"] = TOKEN

try:
yield from self.pages(search_url, params=params, item_key=item_key)
except requests.HTTPError as e:
if e.response.status_code == 400:
raise ValueError(e.response.json()["Message"])
raise

def api_events(self, *args, **kwargs):
"""
For meetings, Metro provides an English audio recording and
Expand Down Expand Up @@ -304,6 +294,9 @@ def scrape(self, window=None):
e.add_source(legistar_api_url, note="api")

if event.get("SAPEventGuid"):
LOGGER.info(
f"Found SAP event for {event['EventBodyName']} on {event['EventDate']}"
)
e.extras["sap_guid"] = event["SAPEventGuid"]

if web_event.has_ecomment:
Expand Down

0 comments on commit 9c0ddd1

Please sign in to comment.