From 4f943759f4c0cea22cbb9321e7d41b49198c190a Mon Sep 17 00:00:00 2001 From: Vxrtrauter <101264710+Vxrtrauter@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:56:14 +0200 Subject: [PATCH] Refactor: steamrip scraper & update menu labels Simplify SteamripScraper link/name extraction by using BeautifulSoup results directly (append absolute URLs and use link.get_text()) and avoid fragile regex; adjust scrape_steamrip_game_downloads to accept a full URL argument. Update context menu text: replace "Copy Magnet URI" with "Copy Download Link" in two places and rename "Download Item" to "Download" for clearer UI wording. --- src/data/sources/steamrip.py | 12 +++++------- src/interface/dialogs/contextmenu.py | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/data/sources/steamrip.py b/src/data/sources/steamrip.py index 71de40e..596688e 100644 --- a/src/data/sources/steamrip.py +++ b/src/data/sources/steamrip.py @@ -37,13 +37,12 @@ class SteamripScraper: links = [] names = [] + for gamehtml in games: link = gamehtml.find("a", href=lambda x: x and x.startswith("/")) - links += re.findall(r'(?<=href=")[^"]*', link.__str__()) - name = gamehtml.find("a", href=lambda x: x and x.startswith("/")) - names += re.findall(r'(?<=\/">)[^<]*', name.__str__()) - - # construct the list[dict[str,str]] + if link: + links.append("https://steamrip.com" + link["href"]) + names.append(link.get_text()) ret = [] @@ -52,8 +51,7 @@ class SteamripScraper: return ret - def scrape_steamrip_game_downloads(self, gamelink): - url = "https://steamrip.com" + gamelink + def scrape_steamrip_game_downloads(self, url): response = requests.get(url) soup = BeautifulSoup(response.text, "html.parser") download_link_elements = soup.find_all("a",class_="shortc-button") diff --git a/src/interface/dialogs/contextmenu.py b/src/interface/dialogs/contextmenu.py index c575623..08ed1f0 100644 --- a/src/interface/dialogs/contextmenu.py +++ b/src/interface/dialogs/contextmenu.py @@ -32,7 +32,7 @@ class ContextMenu_Downloads: self.main_window = main_window self.context_menu = QtWidgets.QMenu(main_window) self.context_menu.addAction("Open Containing Folder", self.openFolderAction) - self.context_menu.addAction("Copy Magnet URI", self.copyMagnetURIAction) + self.context_menu.addAction("Copy Download Link", self.copyMagnetURIAction) self.context_menu.addAction("Remove from list", self.cancelDownloadAction) self.context_menu.addAction("Delete File", self.deleteFileAction) @@ -205,9 +205,9 @@ class ContextMenu_TrackerTable: def __init__(self, main_window): self.main_window = main_window self.context_menu = QtWidgets.QMenu(main_window) - self.context_menu.addAction("Copy Magnet URI", self.copyMagnetURIAction) + self.context_menu.addAction("Copy Download Link", self.copyMagnetURIAction) self.context_menu.addAction("Open in Browser", self.openInBrowserAction) - self.context_menu.addAction("Download Item", self.downloadItemAction) + self.context_menu.addAction("Download", self.downloadItemAction) state.trackertable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) state.trackertable.customContextMenuRequested.connect(self._show_context_menu)