diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9f2418b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + // "python.pythonPath": "/home/lynne/Projects/code/python/buypeeb/venv/bin/python3.8" +} diff --git a/buypeeb.py b/buypeeb.py index 3f26531..da14149 100755 --- a/buypeeb.py +++ b/buypeeb.py @@ -71,6 +71,7 @@ class BuypeebApp: self.window = None self.settings = BuypeebSettings(settingsLocation) self.builder = None + self.selected = None def run(self, argv): self.app.run(argv) @@ -88,6 +89,7 @@ class BuypeebApp: self.setExchangeRate() self.settings.load() + self.resetSidePane() self.renderList() def activate(self, app): @@ -192,6 +194,12 @@ class BuypeebApp: for label, contents in info.items(): self.builder.get_object(f"lblSelected{label}").set_label(contents) + def resetSidePane(self): + for label in ["YahooName", "Price", "PriceAUD", "Ending", "Bids"]: + self.builder.get_object(f"lblSelected{label}").set_label("") + + self.builder.get_object("lblSelectedName").set_label("buypeeb") + # BUTTON CLICKS @@ -199,7 +207,7 @@ class BuypeebApp: url = self.entryBox("Add URL", "Enter the URL of the item you want to add.") if url: # vry simpl url validation for simpol creachers - if functions.rmatch(r"https?.+yahoo.+", url): + if functions.rmatch(r"http.+yahoo.+", url): self.settings.watch(url) else: self.msgBox("Invalid URL", "The provided URL was invalid.", Gtk.MessageType.ERROR) @@ -231,15 +239,32 @@ class BuypeebApp: prompt.format_secondary_text("Are you sure you want to quit buypeeb?") response = prompt.run() - if response: + if response == Gtk.ResponseType.OK: self.shutdown(self) + def btnSelectedRenameClicked(self, widget): + item = self.settings.watchlist[self.selected] + name = self.entryBox("Rename", f"Enter a new name for \"{item.name}\".") + if name: + item.name = name + + self.renderList() # TODO: only update the changed item + + def btnSelectedRemoveClicked(self, widget): + del self.settings.watchlist[self.selected] + self.selected = None + self.renderList() + self.resetSidePane() + # OTHER UI INTERACTIONS def tveItemsSelectionChanged(self, selection): items, treeIter = selection.get_selected() + if treeIter == None: + return row = items[treeIter] id = row[3] + self.selected = id self.updateSidePane(id) if __name__ == '__main__': diff --git a/listing.py b/listing.py index 184aba1..84027af 100644 --- a/listing.py +++ b/listing.py @@ -86,8 +86,8 @@ class YahooAuctionsItem: # the good news is, yahoo japan returns all the data we need in handy json format # the bad news is that the only way to get that json format is to download the whole auction page and grep it - # r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text - r = open("yahoo.html").read() + r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text + # r = open("yahoo.html").read() j = json.loads(re.match(r'.*var pageData ?= ?(\{.*?\});', r, re.DOTALL).group(1)) except: raise diff --git a/ui/main.glade b/ui/main.glade index 1ddc7b9..132219d 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -345,7 +345,7 @@ True False - buypeeb + precious peebus polytonal player center True end @@ -446,6 +446,7 @@ True False end + something in japanese end @@ -458,6 +459,7 @@ True False end + ¥12345 2 @@ -469,6 +471,7 @@ True False end + $123.45 2 @@ -480,6 +483,7 @@ True False end + 1h 17m 23s 2 @@ -491,6 +495,7 @@ True False end + 5 2 @@ -597,11 +602,12 @@ True expand - + True True True - Delete + Remove + True @@ -618,11 +624,12 @@ - + True True True Rename + True @@ -638,7 +645,7 @@ - + True True True @@ -658,7 +665,7 @@ - + True True True