mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
Merge branch 'main' of https://github.com/KeksPirates/SoftwareManager
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import aiohttp
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
global url_uztracker
|
global url_uztracker
|
||||||
@@ -23,7 +24,7 @@ async def init_uztracker():
|
|||||||
|
|
||||||
asyncio.run(init_uztracker())
|
asyncio.run(init_uztracker())
|
||||||
|
|
||||||
def scrape_uztracker(search, debug, max_results=450):
|
async def scrape_uztracker(search, debug, max_results=450):
|
||||||
if up:
|
if up:
|
||||||
result = False
|
result = False
|
||||||
global results
|
global results
|
||||||
@@ -38,12 +39,14 @@ def scrape_uztracker(search, debug, max_results=450):
|
|||||||
if debug:
|
if debug:
|
||||||
print(search_url)
|
print(search_url)
|
||||||
|
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
try:
|
try:
|
||||||
resultCount = 0
|
async with session.get(search_url) as response:
|
||||||
response = requests.get(search_url)
|
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
soup = BeautifulSoup(response.text, 'html.parser')
|
text = await response.text()
|
||||||
|
soup = BeautifulSoup(text, 'html.parser')
|
||||||
links = soup.find_all('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic'))
|
links = soup.find_all('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic'))
|
||||||
|
resultCount = 0
|
||||||
for link in links:
|
for link in links:
|
||||||
if link.b:
|
if link.b:
|
||||||
resultCount += 1
|
resultCount += 1
|
||||||
@@ -55,7 +58,7 @@ def scrape_uztracker(search, debug, max_results=450):
|
|||||||
# add popup in gui for no result
|
# add popup in gui for no result
|
||||||
break
|
break
|
||||||
|
|
||||||
except requests.RequestException as e:
|
except aiohttp.ClientError as e:
|
||||||
if result:
|
if result:
|
||||||
print(f"Failed to fetch {search_url}: {e}")
|
print(f"Failed to fetch {search_url}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from PySide6.QtWidgets import (
|
|||||||
from PySide6.QtGui import QIcon, QAction
|
from PySide6.QtGui import QIcon, QAction
|
||||||
import darkdetect
|
import darkdetect
|
||||||
import threading
|
import threading
|
||||||
|
import asyncio
|
||||||
from core.data.scrapers.uztracker import scrape_uztracker
|
from core.data.scrapers.uztracker import scrape_uztracker
|
||||||
from core.data.scrapers.rutracker import scrape_rutracker
|
from core.data.scrapers.rutracker import scrape_rutracker
|
||||||
from core.data.utils.tracker_utils import get_item_index
|
from core.data.utils.tracker_utils import get_item_index
|
||||||
@@ -123,9 +124,9 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
|
|
||||||
if darkdetect.isDark():
|
if darkdetect.isDark():
|
||||||
settings_action = QAction(QIcon("core/interface/assets/settings_white.png"), "Settings", self)
|
|
||||||
else:
|
|
||||||
settings_action = QAction(QIcon("core/interface/assets/settings_dark.png"), "Settings", self)
|
settings_action = QAction(QIcon("core/interface/assets/settings_dark.png"), "Settings", self)
|
||||||
|
else:
|
||||||
|
settings_action = QAction(QIcon("core/interface/assets/settings.png"), "Settings", self)
|
||||||
|
|
||||||
settings_action.triggered.connect(self.settings_dialog)
|
settings_action.triggered.connect(self.settings_dialog)
|
||||||
toolbar.addAction(settings_action)
|
toolbar.addAction(settings_action)
|
||||||
@@ -258,9 +259,9 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
if debug:
|
if debug:
|
||||||
print("User searched for:", search_text)
|
print("User searched for:", search_text)
|
||||||
if tracker == "uztracker":
|
if tracker == "uztracker":
|
||||||
response = scrape_uztracker(search_text, debug)
|
response = asyncio.run(scrape_uztracker(search_text, debug))
|
||||||
if tracker == "rutracker":
|
if tracker == "rutracker":
|
||||||
response = scrape_rutracker(search_text, debug, api_url)
|
response = asyncio.run(scrape_rutracker(search_text, debug, api_url))
|
||||||
if response:
|
if response:
|
||||||
self.postnames, self.postlinks = response
|
self.postnames, self.postlinks = response
|
||||||
self.softwareList.clear()
|
self.softwareList.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user