From f23f0cbc34ed26aa80c30f7bc330da82ea2084cc Mon Sep 17 00:00:00 2001 From: Romayne <27376947+MeggalBozale@users.noreply.github.com> Date: Sun, 25 Aug 2024 13:44:48 -0400 Subject: [PATCH] add config and run handling to support ignoring auction house / bazaar stuff --- config.py | 2 ++ run.py | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index e3ad597..e53c425 100644 --- a/config.py +++ b/config.py @@ -24,6 +24,8 @@ always_revalidate_key = False # use this if you expect your keys to be invalidated a lot announce_queries = False # debug option, print on each query to debug query optimizaiton disable_cooldown_limiters = True # For having auction house data load faster. Disable if you keep hitting rate limits +include_auction_house = True # In case you dont feel like doing AH stuff +include_bazaar = True # I dunno but i guess cooldown_request_seconds = 1 # 300 per 5mins is listed via API, so 1 per second is compliant json_key_api_key = "api_key" diff --git a/run.py b/run.py index a43fa0f..4ec6641 100644 --- a/run.py +++ b/run.py @@ -38,11 +38,15 @@ def get_item_bz_price(product_data): api.info() - bz = Bazaar(api) + if not include_bazaar and not include_auction_house: + print("No source to compare prices with. Please enable either the auction house and/or the bazaar.") - ah = AuctionHouse(api) + if include_bazaar: + bz = Bazaar(api) - ah_items = ah.get_items_keyed_by("item_name") + if include_auction_house: + ah = AuctionHouse(api) + ah_items = ah.get_items_keyed_by("item_name") item_data = [] @@ -52,16 +56,20 @@ def get_item_bz_price(product_data): coins_for_product = 0 coins_per_bit = 0 ah_entries = 0 - if product_id != None: + is_auction_house_item = False + if include_bazaar and (product_id != None): coins_for_product = get_item_bz_price(bz.whole_bazaar_data["products"][product_id]) coins_for_product *= (1 - BAZAAR_TAX) - elif (item_key in ah_items.keys()): + elif include_auction_house and (item_key in ah_items.keys()): + is_auction_house_item = True ah_entries = len(ah_items[item_key]) coins_for_product = get_item_ah_price(item_key, ah_items) # Fees (Listing BIN) coins_for_product -= get_profits_fee(coins_for_product) # Fees (Duration) coins_for_product -= AUCTION_HOUSE_FEE + else: + continue coins_per_bit = coins_for_product / bit_items[item_key]["cost_bits"] @@ -69,8 +77,8 @@ def get_item_bz_price(product_data): "item_name": item_key, "coins_per_bit": round(coins_per_bit, 2), "coins_for_product": round(coins_for_product, 2), - "on_ah": product_id == None, - "ah_entries": ah_entries + "on_ah": is_auction_house_item, + "ah_entries": ah_entries, }) item_data.sort(key=(lambda s: s["coins_per_bit"]), reverse=True)