Refactor GUI to utilize get_item_index for improved item selection and download handling

This commit is contained in:
Vxrtrauter
2025-09-06 01:00:12 +02:00
parent 87380f57af
commit 01303234d6
2 changed files with 20 additions and 15 deletions
+16 -1
View File
@@ -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)