mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
fix: steamrip scraper freezing whole manager on second search and update notification popup settings and improve megadb notification handling
This commit is contained in:
@@ -17,13 +17,17 @@ def show_megadb_notification():
|
|||||||
text="Beware of malicious Ads. Make sure to have an adblocker installed.\n" '<br><a href="https://ublockorigin.com">Visit uBlock Origin</a>',
|
text="Beware of malicious Ads. Make sure to have an adblocker installed.\n" '<br><a href="https://ublockorigin.com">Visit uBlock Origin</a>',
|
||||||
darkmode=False if state.window_transparency else True
|
darkmode=False if state.window_transparency else True
|
||||||
)
|
)
|
||||||
|
|
||||||
notification_popup.setTextFormat(Qt.TextFormat.RichText)
|
notification_popup.setTextFormat(Qt.TextFormat.RichText)
|
||||||
notification_popup.setTextInteractionFlags(Qt.TextInteractionFlag.TextBrowserInteraction)
|
notification_popup.setTextInteractionFlags(Qt.TextInteractionFlag.TextBrowserInteraction)
|
||||||
|
|
||||||
if state.window_transparency is True:
|
if state.window_transparency is True:
|
||||||
notification_popup.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
notification_popup.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
|
|
||||||
button = notification_popup.addButton("Don't show again", QMessageBox.ButtonRole.AcceptRole)
|
button = notification_popup.addButton("Don't show again", QMessageBox.ButtonRole.AcceptRole)
|
||||||
button.clicked.connect(lambda: setattr(state, "show_megadb_notification", False))
|
button.clicked.connect(lambda: setattr(state, "show_megadb_notification", False))
|
||||||
save_settings(show_megadb_notification=False)
|
|
||||||
|
save_settings(show_megadb_notification=state.show_megadb_notification)
|
||||||
notification_popup.exec()
|
notification_popup.exec()
|
||||||
|
|
||||||
def scrape_megadb(url):
|
def scrape_megadb(url):
|
||||||
|
|||||||
@@ -9,23 +9,22 @@ import webbrowser
|
|||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import copy
|
||||||
|
|
||||||
class SteamripScraper:
|
class SteamripScraper:
|
||||||
name = "steamrip"
|
name = "steamrip"
|
||||||
headers = ["Game"]
|
headers = ["Game"]
|
||||||
is_magnet = False
|
is_magnet = False
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cache = { "data": [], "last_fetched": 0 }
|
self.cache = { "data": [], "last_fetched": 0 }
|
||||||
self.cache_expiry = 300
|
self.cache_expiry = 300
|
||||||
|
|
||||||
def scrape_steamrip_links(self):
|
def scrape_steamrip_links(self):
|
||||||
|
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
|
|
||||||
if self.cache["data"] != [] and (current_time - self.cache["last_fetched"] < self.cache_expiry):
|
if self.cache["data"] and (current_time - self.cache["last_fetched"] < self.cache_expiry):
|
||||||
return self.cache["data"]
|
return copy.deepcopy(self.cache["data"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = f"https://steamrip.com/games-list-page/"
|
url = f"https://steamrip.com/games-list-page/"
|
||||||
@@ -71,7 +70,7 @@ class SteamripScraper:
|
|||||||
|
|
||||||
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")
|
||||||
download_links = ["buzzheavier", "gofile", "vikingfile", "megadb"]
|
download_links = ["", "", "", ""]
|
||||||
|
|
||||||
for download_link in download_link_elements:
|
for download_link in download_link_elements:
|
||||||
pure = download_link.attrs.get("href")
|
pure = download_link.attrs.get("href")
|
||||||
@@ -89,7 +88,7 @@ class SteamripScraper:
|
|||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
for link in download_links:
|
for link in download_links:
|
||||||
if len(link) != 1:
|
if link != "":
|
||||||
ret.append(link)
|
ret.append(link)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from PySide6.QtWidgets import QMessageBox
|
from PySide6.QtWidgets import QMessageBox
|
||||||
|
from utils.data.state import state
|
||||||
import qdarktheme
|
import qdarktheme
|
||||||
|
|
||||||
class NotificationPopup(QMessageBox):
|
class NotificationPopup(QMessageBox):
|
||||||
@@ -6,7 +7,10 @@ class NotificationPopup(QMessageBox):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
if darkmode is True:
|
if darkmode is True:
|
||||||
qdarktheme.setup_theme("auto")
|
custom_colors = {}
|
||||||
|
if state.accent_color:
|
||||||
|
custom_colors["primary"] = state.accent_color
|
||||||
|
qdarktheme.setup_theme("auto", custom_colors=custom_colors if custom_colors else None)
|
||||||
|
|
||||||
self.setIcon(QMessageBox.Icon.Information)
|
self.setIcon(QMessageBox.Icon.Information)
|
||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
|
|||||||
Reference in New Issue
Block a user