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