From 445df6ba2137f71a8f853cd0593f5ec768df0819 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Mon, 1 May 2023 10:04:32 -0700 Subject: [PATCH] If there is no price available, say so --- app/star_citizen.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/app/star_citizen.py b/app/star_citizen.py index b734fdf1..2325cf39 100644 --- a/app/star_citizen.py +++ b/app/star_citizen.py @@ -53,30 +53,27 @@ async def get_ship(ship_name): embed.add_field(name="**Role**", value=ship_role) - try: - # ingame_price = ( - # soup.find("div", {"class": "data-buycost infobox-data infobox-col2"}) - # .find("div", {"class": "infobox-data__value"}) - # .text - # ) + # ingame_price = ( + # soup.find("div", {"class": "data-buycost infobox-data infobox-col2"}) + # .find("div", {"class": "infobox-data__value"}) + # .text + # ) - # Hideous code for "where to buy" in game - table = soup.find("span", {"id": "Buying"}).findNext( - "table", {"class": "wikitable"} - ) + # Hideous code for "where to buy" in game + table = soup.find("span", {"id": "Buying"}).findNext( + "table", {"class": "wikitable"} + ) - locations = [x.text.replace("\n", "") for x in table.find_all("th")] - prices = [x.text.replace("\n", "") for x in table.find_all("td")] - zip_list = zip(locations, prices) + locations = [x.text.replace("\n", "") for x in table.find_all("th")] + prices = [x.text.replace("\n", "") for x in table.find_all("td")] + zip_list = zip(locations, prices) - result = list(zip_list) - ingame_price = [x for x in result if "Unavailable" not in x] - for x in ingame_price: - ingame_price = " ".join(x) + " aUEC" + result = list(zip_list) + ingame_price = [x for x in result if "Unavailable" not in x] + for x in ingame_price: + ingame_price = " ".join(x) + " aUEC" - # embed.add_field(name="**Where to buy**", value=result, inline=True) - - except Exception: + if not len(ingame_price): ingame_price = "No in-game price available" embed.add_field(name="**Ingame Price**", value=ingame_price, inline=True)