From 9c8ffee5ce12648f46cdb2137bee8fb509fb5694 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 24 Aug 2020 18:09:46 +1000 Subject: [PATCH] show buy it now price, if any --- buypeeb.py | 12 ++++++++++-- listing.py | 23 ++++++++++++++++++----- ui/main.glade | 4 ++-- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/buypeeb.py b/buypeeb.py index 47a519a..a6bd8a0 100755 --- a/buypeeb.py +++ b/buypeeb.py @@ -75,6 +75,11 @@ class WatchlistUpdater(Thread): future = pool.schedule(item.update) future.add_done_callback(watchlist_update_done) + pool.close() + pool.join() + if app.selected: + app.updateSidePane(app.selected) + class BuypeebApp: # SETUP @@ -214,14 +219,17 @@ class BuypeebApp: "Price": item.price_jpy(), "PriceAUD": item.price_aud(), "Ending": item.ending_in(), - "Bids": str(item.bids) + "Bids": str(item.bids), + "BuyItNow": f"{item.price_jpy(win = True)} ({item.price_aud(win = True)})" if item.win_price not in [0, "0", None, ""] else "No", + "AutoExtension": "Yes" if item.auto_extension else "No", + "LastUpdated": "Last updated: heenlo" } for label, contents in info.items(): self.builder.get_object(f"lblSelected{label}").set_label(contents if contents is not None else "") def resetSidePane(self): - for label in ["YahooName", "Price", "PriceAUD", "Ending", "Bids"]: + for label in ["YahooName", "Price", "PriceAUD", "Ending", "Bids", "BuyItNow", "AutoExtension", "LastUpdated"]: self.builder.get_object(f"lblSelected{label}").set_label("") self.builder.get_object("lblSelectedName").set_label("buypeeb") diff --git a/listing.py b/listing.py index 48f997e..5e99a8e 100644 --- a/listing.py +++ b/listing.py @@ -61,7 +61,8 @@ class YahooAuctionsItem: self.favourite = None self.end_date = None self.bids = 0 - self.automatic_extension = None + self.auto_extension = None + self.rate = 75.0 if url == None and from_json != None and id != None: self.id = id @@ -96,13 +97,14 @@ class YahooAuctionsItem: ae = re.match(r'自動延長.+\n.+>(.+)<.+', r) if ae != None: ae = re.group(1) - self.automatic_extension = (ae == "あり") + self.auto_extension = (ae == "あり") except: raise j = j['items'] self.price = float(j['price']) + self.win_price = float(j['winPrice']) self.bids = j['bids'] self.start_date = datetime.fromisoformat(j['starttime']).replace(tzinfo = JST) self.end_date = datetime.fromisoformat(j['endtime']).replace(tzinfo = JST) @@ -116,10 +118,21 @@ class YahooAuctionsItem: return self.id, self - def price_jpy(self): - return f"¥{self.price:.0f}" + def price_jpy(self, win = False): + p = self.price + if win: + p = self.win_price + return f"¥{p:.0f}" - def price_aud(self, rate = 75.0): + def price_aud(self, rate = 0, win = False): + if rate == 0: + rate = self.rate + else: + self.rate = rate + + p = self.price + if win: + p = self.win_price return f"${self.price / rate:.2f}" def ending_in(self): diff --git a/ui/main.glade b/ui/main.glade index ea1acf4..7dcf144 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -590,7 +590,7 @@ - + True False end @@ -602,7 +602,7 @@ - + True False end