From f9c03cb336570a6d7913deb759c96a18e159b852 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 13 Oct 2023 20:25:07 -0700 Subject: [PATCH] Simplify the incident_url getting code and also change the image on /drug to be etam --- app/cogs/star_citizen.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/cogs/star_citizen.py b/app/cogs/star_citizen.py index 052f5176..d8c354eb 100644 --- a/app/cogs/star_citizen.py +++ b/app/cogs/star_citizen.py @@ -52,7 +52,7 @@ class StarCitizen(commands.Cog): ) embed.set_thumbnail( - url="https://i.ebayimg.com/images/g/IvQAAOSwjyhaOTZN/s-l1200.webp" + url="https://media.starcitizen.tools/3/31/ViceCommodity_E%27tam.jpg" ) embed.set_author(name="Ranking of drugs by sell price") @@ -230,11 +230,12 @@ class StarCitizen(commands.Cog): status_json = requests.get(status_url + "/index.json").json() if status_json["summaryStatus"] != "ok": - # Look at all the systems in the API and filter out the ones whos "unresolvedIssues" list is not empty, - # Then parse out the "permalink" value - current_incident_url = list( - filter(lambda x: len(x["unresolvedIssues"]), status_json["systems"]) - )[0]["unresolvedIssues"][0]["permalink"].replace("'", "") + # Extract systems with unresolved issues + systems_with_issues = [system for system in status_json["systems"] if system["unresolvedIssues"]] + + unresolved_issue_permalink = systems_with_issues[0]["unresolvedIssues"][0]["permalink"] + # Remove any single quote characters from the URL + current_incident_url = unresolved_issue_permalink.replace("'", "") response = requests.get(current_incident_url).text incident_soup = BeautifulSoup(response, "html.parser")