mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
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:
@@ -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")
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user