From 7cc79e69cb98588ab846264dc6e3ad7009e6bc65 Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Wed, 3 Sep 2025 22:16:30 +0200 Subject: [PATCH] Code Cleanup --- core/downloading/download.py | 2 +- core/gui.py | 18 ++--------- core/{ => scraping}/uztracker_scraper.py | 39 +++--------------------- main.py | 7 ----- 4 files changed, 8 insertions(+), 58 deletions(-) rename core/{ => scraping}/uztracker_scraper.py (67%) diff --git a/core/downloading/download.py b/core/downloading/download.py index 227cbeb..e6e2d4b 100644 --- a/core/downloading/download.py +++ b/core/downloading/download.py @@ -1,5 +1,5 @@ from .aria2p_server import run_aria2p -# from .scraper import uri + def start_client(): global aria2 aria2 = run_aria2p() diff --git a/core/gui.py b/core/gui.py index 5095b72..7bc2cb2 100644 --- a/core/gui.py +++ b/core/gui.py @@ -4,8 +4,8 @@ from PySide6.QtWidgets import QLineEdit, QWidget, QVBoxLayout, QListWidget, QToo from PySide6.QtGui import QIcon, QAction import sys import darkdetect -from core.uztracker_scraper import scrape_uztracker -from core.uztracker_scraper import get_magnet_link +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 @@ -101,16 +101,4 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): print(selected) selected_magnet = get_magnet_link(selected) start_client() - add_magnet(selected_magnet) - -def run_gui(): - app = QtWidgets.QApplication([]) - - widget = MainWindow() - widget.show() - - sys.exit(app.exec()) - - -if __name__ == "__main__": - run_gui() + add_magnet(selected_magnet) \ No newline at end of file diff --git a/core/uztracker_scraper.py b/core/scraping/uztracker_scraper.py similarity index 67% rename from core/uztracker_scraper.py rename to core/scraping/uztracker_scraper.py index a0ea8b8..44018e6 100644 --- a/core/uztracker_scraper.py +++ b/core/scraping/uztracker_scraper.py @@ -50,24 +50,6 @@ def get_post_title(post_url): else: print("Program not found") - -def select_program(): - selection = input("Enter the Number of the Program you want to download: ") - - - try: - index = int(selection) - 1 - if 0 <= index < len(results): # 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/" + results[index].lstrip("./") - post_url = selected - return selected - else: - print("Invalid Selection.") - - except ValueError: - print(Exception) - return - def get_magnet_link(post_url): try: @@ -82,21 +64,8 @@ def get_magnet_link(post_url): except requests.RequestException as e: print(f"Failed to fetch {post_url}: {e}") - # What x and x.startswith('magnet:') Does - - # x - check if x exists (not None/empty) - # and - if x exists, THEN check the next part - # x.startswith('magnet:') - does x start with "magnet:"? - - - - -if __name__ == "__main__": - search_input = input("Enter the Name of the Program you want to search for: ") - selected = scrape_uztracker(search_input) - maintitle = get_post_title(selected) - magnetlink = get_magnet_link(selected) - print(maintitle) - print(magnetlink) - +# What x and x.startswith('magnet:') Does +# x - check if x exists (not None/empty) +# and - if x exists, THEN check the next part +# x.startswith('magnet:') - does x start with "magnet:"? diff --git a/main.py b/main.py index e1b6320..0278723 100644 --- a/main.py +++ b/main.py @@ -1,15 +1,9 @@ -from core.gui import run_gui as gui from core.gui import MainWindow -from PySide6.QtGui import QIcon, QAction from PySide6 import QtWidgets import qdarktheme import darkdetect import sys - - - - def run_gui(): app = QtWidgets.QApplication([]) if darkdetect.isDark: @@ -21,6 +15,5 @@ def run_gui(): sys.exit(app.exec()) - if __name__ == "__main__": run_gui()