Compare commits

...

2 commits

Author SHA1 Message Date
9c8ffee5ce
show buy it now price, if any 2020-08-24 18:09:46 +10:00
0a73423195
added columns for automatic extension and buy it now 2020-08-24 17:41:23 +10:00
3 changed files with 87 additions and 6 deletions

View file

@ -75,6 +75,11 @@ class WatchlistUpdater(Thread):
future = pool.schedule(item.update) future = pool.schedule(item.update)
future.add_done_callback(watchlist_update_done) future.add_done_callback(watchlist_update_done)
pool.close()
pool.join()
if app.selected:
app.updateSidePane(app.selected)
class BuypeebApp: class BuypeebApp:
# SETUP # SETUP
@ -214,14 +219,17 @@ class BuypeebApp:
"Price": item.price_jpy(), "Price": item.price_jpy(),
"PriceAUD": item.price_aud(), "PriceAUD": item.price_aud(),
"Ending": item.ending_in(), "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(): for label, contents in info.items():
self.builder.get_object(f"lblSelected{label}").set_label(contents if contents is not None else "") self.builder.get_object(f"lblSelected{label}").set_label(contents if contents is not None else "")
def resetSidePane(self): 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(f"lblSelected{label}").set_label("")
self.builder.get_object("lblSelectedName").set_label("buypeeb") self.builder.get_object("lblSelectedName").set_label("buypeeb")

View file

@ -61,6 +61,8 @@ class YahooAuctionsItem:
self.favourite = None self.favourite = None
self.end_date = None self.end_date = None
self.bids = 0 self.bids = 0
self.auto_extension = None
self.rate = 75.0
if url == None and from_json != None and id != None: if url == None and from_json != None and id != None:
self.id = id self.id = id
@ -92,11 +94,17 @@ class YahooAuctionsItem:
r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text
# r = open("yahoo.html").read() # r = open("yahoo.html").read()
j = json.loads(re.match(r'.*var pageData ?= ?(\{.*?\});', r, re.DOTALL).group(1)) j = json.loads(re.match(r'.*var pageData ?= ?(\{.*?\});', r, re.DOTALL).group(1))
ae = re.match(r'自動延長.+\n.+>(.+)<.+', r)
if ae != None:
ae = re.group(1)
self.auto_extension = (ae == "あり")
except: except:
raise raise
j = j['items'] j = j['items']
self.price = float(j['price']) self.price = float(j['price'])
self.win_price = float(j['winPrice'])
self.bids = j['bids'] self.bids = j['bids']
self.start_date = datetime.fromisoformat(j['starttime']).replace(tzinfo = JST) self.start_date = datetime.fromisoformat(j['starttime']).replace(tzinfo = JST)
self.end_date = datetime.fromisoformat(j['endtime']).replace(tzinfo = JST) self.end_date = datetime.fromisoformat(j['endtime']).replace(tzinfo = JST)
@ -110,10 +118,21 @@ class YahooAuctionsItem:
return self.id, self return self.id, self
def price_jpy(self): def price_jpy(self, win = False):
return f"¥{self.price:.0f}" 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}" return f"${self.price / rate:.2f}"
def ending_in(self): def ending_in(self):

View file

@ -18,7 +18,7 @@
<data> <data>
<row> <row>
<col id="0" translatable="yes">The Stinchinator</col> <col id="0" translatable="yes">The Stinchinator</col>
<col id="1" translatable="yes"/> <col id="1" translatable="yes">¥599</col>
<col id="2" translatable="yes">$5.99</col> <col id="2" translatable="yes">$5.99</col>
<col id="3" translatable="yes">7 hours</col> <col id="3" translatable="yes">7 hours</col>
<col id="4" translatable="yes">12345</col> <col id="4" translatable="yes">12345</col>
@ -565,6 +565,60 @@
<property name="top_attach">0</property> <property name="top_attach">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Buy it now?</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Auto extension?</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblSelectedBuyItNow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Yes</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblSelectedAutoExtension">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">N/A</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>