Fixes #1 Adding event organizer to the /trackdays blurb and also fixing it so if an org only has one day, it will still show up
This commit is contained in:
parent
d940f287cd
commit
fe4a1588f8
@ -132,7 +132,12 @@ class ActualUtils(commands.Cog):
|
|||||||
)
|
)
|
||||||
for track_day in events:
|
for track_day in events:
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="-------------\n**Event Name**",
|
name="-------------\n**Organizer**",
|
||||||
|
value=track_day["event_organizer"],
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="**Event Name**",
|
||||||
value=track_day["event_name"],
|
value=track_day["event_name"],
|
||||||
inline=False,
|
inline=False,
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,6 @@ async def get_msreg(track):
|
|||||||
"turn8": "F3469266-BEFF-E329-4FD6C4B189ACE2A8",
|
"turn8": "F3469266-BEFF-E329-4FD6C4B189ACE2A8",
|
||||||
"speedventures": "DF7453ED-BF33-DC17-2C9BFD84C1F05E86",
|
"speedventures": "DF7453ED-BF33-DC17-2C9BFD84C1F05E86",
|
||||||
"nextlevel": "CC23AEA4-AAB1-D087-4A10818D229DAFD2",
|
"nextlevel": "CC23AEA4-AAB1-D087-4A10818D229DAFD2",
|
||||||
"corsaclub": "CE6E69CF-BAEC-DBB6-303EE7D3EC69B8A3",
|
|
||||||
"lightspeed": "BC6417B8-0ED9-DD48-28BA1463C2C14322",
|
"lightspeed": "BC6417B8-0ED9-DD48-28BA1463C2C14322",
|
||||||
"socaldriversclub": "B4FC0113-C903-E9D3-68562D6765806945",
|
"socaldriversclub": "B4FC0113-C903-E9D3-68562D6765806945",
|
||||||
}
|
}
|
||||||
@ -35,10 +34,16 @@ async def get_msreg(track):
|
|||||||
json.dumps(xmltodict.parse(awaited_xml_blob)["response"]["events"])
|
json.dumps(xmltodict.parse(awaited_xml_blob)["response"]["events"])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If an organizer only has one upcoming event on MSReg, it is a dict, otherwise its a list of dicts
|
||||||
|
# My code assumes list of dicts, so wrap the event dict in a list of 1 item
|
||||||
|
if json_blob and isinstance(json_blob["event"], dict):
|
||||||
|
json_blob["event"] = [json_blob["event"]]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for event in json_blob["event"]:
|
for event in json_blob["event"]:
|
||||||
if any(x in event["name"].lower() for x in tracks_we_care_about):
|
if any(x in event["name"].lower() for x in tracks_we_care_about):
|
||||||
event_object = {
|
event_object = {
|
||||||
|
"event_organizer": event["organization"]["name"],
|
||||||
"event_name": event["name"],
|
"event_name": event["name"],
|
||||||
"event_url": event["detailuri"].split("?utm")[0],
|
"event_url": event["detailuri"].split("?utm")[0],
|
||||||
"event_date": event["start"],
|
"event_date": event["start"],
|
||||||
@ -55,7 +60,9 @@ async def get_msreg(track):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
except TypeError:
|
except Exception as e:
|
||||||
|
print("Errored on %s" % org_name)
|
||||||
|
print(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return events
|
return events
|
||||||
@ -68,7 +75,6 @@ def get_corsa_club():
|
|||||||
for event in products_blob:
|
for event in products_blob:
|
||||||
# Filter out hoodies and what not, only care about track days that list run-groups as the options
|
# Filter out hoodies and what not, only care about track days that list run-groups as the options
|
||||||
if any("Intermediate" in s for s in event["options"][0]["values"]):
|
if any("Intermediate" in s for s in event["options"][0]["values"]):
|
||||||
# pp.pprint(event)
|
|
||||||
event_object = {
|
event_object = {
|
||||||
"event_name": event["title"],
|
"event_name": event["title"],
|
||||||
"event_url": base_url + "/products/" + event["handle"],
|
"event_url": base_url + "/products/" + event["handle"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user