mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
Refactor GUI to utilize get_item_index for improved item selection and download handling
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import requests
|
||||
import asyncio
|
||||
from bs4 import BeautifulSoup
|
||||
from ..downloading.download import start_client
|
||||
from ..downloading.download import add_magnet
|
||||
|
||||
global url_uztracker
|
||||
global up
|
||||
url_uztracker = "https://uztracker.net/tracker.php?nm=" # placeholder url for now
|
||||
|
||||
async def init_uztracker():
|
||||
global up
|
||||
global soup
|
||||
try:
|
||||
response = requests.get(url_uztracker) # get da content from da url
|
||||
soup = BeautifulSoup(response.content, 'html.parser') # create bs object
|
||||
@@ -103,3 +106,15 @@ def get_magnet_link(post_url, debug):
|
||||
# and - if x exists, THEN check the next part
|
||||
# x.startswith('magnet:') - does x start with "magnet:"?
|
||||
|
||||
|
||||
|
||||
def get_item_index(item, list, listlinks, debug):
|
||||
position = list.index(item)
|
||||
if 0 <= position < len(listlinks): # note for myself: py starts counting at 0; check if number is not negative, check if number is not more than list length.
|
||||
selected = "https://uztracker.net/" + listlinks[position].lstrip("./")
|
||||
post_url = selected
|
||||
if debug:
|
||||
print("Selected URL: ", selected)
|
||||
selected_magnet = get_magnet_link(selected, debug)
|
||||
start_client()
|
||||
add_magnet(selected_magnet)
|
||||
|
||||
+4
-14
@@ -4,9 +4,8 @@ from PySide6.QtWidgets import QLineEdit, QPushButton, QWidget, QVBoxLayout, QLis
|
||||
from PySide6.QtGui import QIcon, QAction
|
||||
import darkdetect
|
||||
from core.scraping.uztracker_scraper import scrape_uztracker
|
||||
from core.scraping.uztracker_scraper import get_magnet_link
|
||||
from core.downloading.download import start_client
|
||||
from core.downloading.download import add_magnet
|
||||
from core.scraping.uztracker_scraper import get_item_index
|
||||
|
||||
|
||||
|
||||
def state_debug(setting):
|
||||
@@ -106,7 +105,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
if item is not None:
|
||||
if debug:
|
||||
print(f"Downloading {self.softwareList.currentItem().text()}")
|
||||
self.get_item_index(self.softwareList.currentItem().text(), self.postnames, self.postlinks)
|
||||
get_item_index(self.softwareList.currentItem().text(), self.postnames, self.postlinks, debug)
|
||||
else:
|
||||
if debug:
|
||||
print("No item selected for download.")
|
||||
@@ -131,13 +130,4 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
print("User searched for:", search_text)
|
||||
|
||||
|
||||
def get_item_index(self, item, list, listlinks):
|
||||
position = list.index(item)
|
||||
if 0 <= position < len(listlinks): # note for myself: py starts counting at 0; check if number is not negative, check if number is not more than list length.
|
||||
selected = "https://uztracker.net/" + listlinks[position].lstrip("./")
|
||||
post_url = selected
|
||||
if debug:
|
||||
print("Selected URL: ", selected)
|
||||
selected_magnet = get_magnet_link(selected, debug)
|
||||
start_client()
|
||||
add_magnet(selected_magnet)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user