Compare commits
2 commits
59fcaae36a
...
fabf38c736
Author | SHA1 | Date | |
---|---|---|---|
fabf38c736 | |||
aeb015568e |
2 changed files with 38 additions and 10 deletions
|
@ -198,7 +198,7 @@ class BuypeebApp:
|
|||
|
||||
self.items.set(treeIter, 0, item.name if item.name is not None else "")
|
||||
if item.ready:
|
||||
listing[1], listing[2], listing[3] = item.price_jpy(), item.price_aud(), item.ending_at()
|
||||
listing[1], listing[2], listing[3] = item.price_jpy(), item.price_aud(), item.ending_at(True)
|
||||
else:
|
||||
listing[0] = "Loading..." if item.name == "" else item.name
|
||||
for i in range(1, 4):
|
||||
|
@ -208,7 +208,7 @@ class BuypeebApp:
|
|||
def updateListTimes(self):
|
||||
for listing in self.items:
|
||||
item = self.settings.watchlist[listing[4]]
|
||||
listing[3] = item.ending_at()
|
||||
listing[3] = item.ending_at(True)
|
||||
|
||||
def updateSidePane(self, id: str):
|
||||
item = self.settings.watchlist[id]
|
||||
|
@ -218,7 +218,7 @@ class BuypeebApp:
|
|||
"YahooName": item.original_name,
|
||||
"Price": item.price_jpy(),
|
||||
"PriceAUD": item.price_aud(),
|
||||
"Ending": item.ending_in(),
|
||||
"Ending": item.ending_in(True),
|
||||
"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",
|
||||
|
|
42
listing.py
42
listing.py
|
@ -1,11 +1,12 @@
|
|||
import requests
|
||||
|
||||
import re, json
|
||||
import re, json, math
|
||||
from datetime import datetime, timezone, timedelta
|
||||
|
||||
import functions
|
||||
|
||||
JST = timezone(timedelta(hours = 9))
|
||||
LOCALTIME = timezone(timedelta(hours = 10)) # TODO: allow for customisation
|
||||
|
||||
class YahooAuctionsItem:
|
||||
"""
|
||||
|
@ -60,7 +61,8 @@ class YahooAuctionsItem:
|
|||
self.win_price = 0
|
||||
self.original_name = ""
|
||||
self.favourite = None
|
||||
self.end_date = None
|
||||
self.end_date = datetime.fromisoformat('1970-01-01').replace(tzinfo = JST)
|
||||
self.start_date = datetime.fromisoformat('1970-01-01').replace(tzinfo = JST)
|
||||
self.bids = 0
|
||||
self.auto_extension = None
|
||||
self.rate = 75.0
|
||||
|
@ -114,6 +116,8 @@ class YahooAuctionsItem:
|
|||
if self.name == None or self.name == "":
|
||||
self.name = j['productName']
|
||||
|
||||
self.available = (self.end_date_local() >= datetime.now(LOCALTIME))
|
||||
|
||||
self.ready = True
|
||||
self.updating = False
|
||||
|
||||
|
@ -136,14 +140,38 @@ class YahooAuctionsItem:
|
|||
p = self.win_price
|
||||
return f"${self.price / rate:.2f}"
|
||||
|
||||
def ending_in(self):
|
||||
return "heenlo"
|
||||
def end_date_local(self):
|
||||
return self.end_date.astimezone(LOCALTIME)
|
||||
|
||||
def ending_at(self):
|
||||
now = datetime.now()
|
||||
def start_date_local(self):
|
||||
return self.start_date.astimezone(LOCALTIME)
|
||||
|
||||
def ending_in(self, local = False):
|
||||
if local:
|
||||
difference = self.end_date_local() - datetime.now(tz = LOCALTIME)
|
||||
else:
|
||||
difference = self.end_date - datetime.now(tz = JST)
|
||||
|
||||
ds = int(difference.total_seconds())
|
||||
|
||||
seconds = ds % 60
|
||||
minutes = math.floor(ds / 60) % 60
|
||||
hours = math.floor(ds / (60 * 60)) % 24
|
||||
days = math.floor(ds / (60 * 60 * 24))
|
||||
|
||||
out = ""
|
||||
if days > 0: out += f"{days}d "
|
||||
if hours > 0: out += f"{hours}h "
|
||||
if minutes > 0: out += f"{minutes}m "
|
||||
|
||||
return f"{out}{seconds}s"
|
||||
|
||||
def ending_at(self, local = False):
|
||||
now = datetime.now(tz = LOCALTIME)
|
||||
ndate = now.strftime("%d %b")
|
||||
if self.end_date != None:
|
||||
idate, itime = self.end_date.strftime("%d %b"), self.end_date.strftime("%H:%M")
|
||||
ed = self.end_date_local() if local else self.end_date
|
||||
idate, itime = ed.strftime("%d %b"), ed.strftime("%H:%M")
|
||||
if idate == ndate:
|
||||
return itime
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue