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.
This commit is contained in:
Vxrtrauter
2026-04-09 23:56:14 +02:00
parent eb9d5d60d1
commit 4f943759f4
2 changed files with 8 additions and 10 deletions
+5 -7
View File
@@ -37,13 +37,12 @@ class SteamripScraper:
links = [] links = []
names = [] names = []
for gamehtml in games: for gamehtml in games:
link = gamehtml.find("a", href=lambda x: x and x.startswith("/")) link = gamehtml.find("a", href=lambda x: x and x.startswith("/"))
links += re.findall(r'(?<=href=")[^"]*', link.__str__()) if link:
name = gamehtml.find("a", href=lambda x: x and x.startswith("/")) links.append("https://steamrip.com" + link["href"])
names += re.findall(r'(?<=\/">)[^<]*', name.__str__()) names.append(link.get_text())
# construct the list[dict[str,str]]
ret = [] ret = []
@@ -52,8 +51,7 @@ class SteamripScraper:
return ret return ret
def scrape_steamrip_game_downloads(self, gamelink): def scrape_steamrip_game_downloads(self, url):
url = "https://steamrip.com" + gamelink
response = requests.get(url) response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser") soup = BeautifulSoup(response.text, "html.parser")
download_link_elements = soup.find_all("a",class_="shortc-button") download_link_elements = soup.find_all("a",class_="shortc-button")
+3 -3
View File
@@ -32,7 +32,7 @@ class ContextMenu_Downloads:
self.main_window = main_window self.main_window = main_window
self.context_menu = QtWidgets.QMenu(main_window) self.context_menu = QtWidgets.QMenu(main_window)
self.context_menu.addAction("Open Containing Folder", self.openFolderAction) 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("Remove from list", self.cancelDownloadAction)
self.context_menu.addAction("Delete File", self.deleteFileAction) self.context_menu.addAction("Delete File", self.deleteFileAction)
@@ -205,9 +205,9 @@ class ContextMenu_TrackerTable:
def __init__(self, main_window): def __init__(self, main_window):
self.main_window = main_window self.main_window = main_window
self.context_menu = QtWidgets.QMenu(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("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.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
state.trackertable.customContextMenuRequested.connect(self._show_context_menu) state.trackertable.customContextMenuRequested.connect(self._show_context_menu)