diff --git a/core/clinterface.py b/core/clinterface.py deleted file mode 100644 index 02d9d34..0000000 --- a/core/clinterface.py +++ /dev/null @@ -1,2 +0,0 @@ -commandinput = input("Enter Command: ") -print(commandinput) \ No newline at end of file diff --git a/core/commands/uztracker.py b/core/commands/uztracker.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/gui.py b/core/gui.py deleted file mode 100644 index 4228049..0000000 --- a/core/gui.py +++ /dev/null @@ -1,68 +0,0 @@ -from PySide6 import QtWidgets -from PySide6.QtCore import Qt -from PySide6.QtWidgets import QLayoutItem, QLineEdit, QWidget, QVBoxLayout, QHBoxLayout, QListWidget, QListWidgetItem, QLabel, QPushButton -import sys -from uztracker_scraper import scrape_uztracker - - -class MainWindow(QtWidgets.QMainWindow, QWidget): - def __init__(self): - super().__init__() - searchresults = [] - - self.setWindowTitle("Software Manager") - self.setGeometry(100, 100, 800, 600) - - self.controls = QWidget() - self.controlsLayout = QVBoxLayout() - - # Widgets - self.searchbar = QLineEdit() - self.searchbar.setPlaceholderText("Search for software...") - self.searchbar.setClearButtonEnabled(True) - self.searchbar.setMinimumHeight(30) - self.searchbar.returnPressed.connect(self.return_pressed) - - self.button = QtWidgets.QPushButton("Download") - self.softwareList = QListWidget() - - container = QWidget() - containerLayout = QVBoxLayout() - containerLayout.addWidget(self.searchbar) - - containerLayout.addWidget(self.softwareList) - self.softwareList.addItems(searchresults) - - - containerLayout.addWidget(self.button) - self.button.clicked.connect(lambda: print(f"Downloading {self.softwareList.currentItem().text()}"), ) - - - container.setLayout(containerLayout) - self.setCentralWidget(container) - - containerLayout.setAlignment(Qt.AlignmentFlag.AlignBottom) - - def return_pressed(self): - search_text = self.searchbar.text() - self.postnames, self.postlinks = scrape_uztracker(search_text) - self.softwareList.clear() - if self.postnames: - self.softwareList.addItems(self.postnames) - print("User searched for:", search_text) - - - - - -def run_gui(): - app = QtWidgets.QApplication([]) - - widget = MainWindow() - widget.show() - - sys.exit(app.exec()) - - -if __name__ == "__main__": - run_gui() diff --git a/core/uztracker_scraper.py b/core/uztracker_scraper.py index a0ea8b8..7fffcd7 100644 --- a/core/uztracker_scraper.py +++ b/core/uztracker_scraper.py @@ -91,12 +91,6 @@ def get_magnet_link(post_url): -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) + diff --git a/main.py b/main.py index 1fdd68d..16b3431 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,56 @@ -from core.gui import run_gui +from ui.clinterface import asciititle; +from core.uztracker_scraper import scrape_uztracker; +import os + + + +def search(): + asciititle() + searchquery = input("Enter Search Query: ") + result = scrape_uztracker(searchquery) + if result is None: + clear() + asciititle() + print("No results found for your Query.\n") + return + return result + +def select_result(result): + resulttitles, resultlinks = result + clear() + asciititle() + for i, title in enumerate(resulttitles, 1): + print(f"({i}) {title}") + selection = input("\n Enter the Number of the Program you want to download: ") + + + try: + index = int(selection) - 1 + if 0 <= index < len(resultlinks): # 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/" + resultlinks[index].lstrip("./") + post_url = selected + return selected + else: + print("Invalid Selection.") + + except ValueError: + print(Exception) + return + + +def clear(): + os.system('cls' if os.name == 'nt' else 'clear') -run_gui() \ No newline at end of file + + + +if __name__ == "__main__": + clear() + results = search() + selected = select_result(results) + print(selected) + + diff --git a/ui/clinterface.py b/ui/clinterface.py new file mode 100644 index 0000000..ee976e2 --- /dev/null +++ b/ui/clinterface.py @@ -0,0 +1,15 @@ + +def asciititle(): + print(f""" + + _____ __ _ __ __ + / ____| / _| | | \/ | +| (___ ___ | |_| |___ ____ _ _ __ ___| \ / | __ _ _ __ __ _ __ _ ___ _ __ + \___ \ / _ \| _| __\ \ /\ / / _` | '__/ _ \ |\/| |/ _` | '_ \ / _` |/ _` |/ _ \ '__| + ____) | (_) | | | |_ \ V V / (_| | | | __/ | | | (_| | | | | (_| | (_| | __/ | +|_____/ \___/|_| \__| \_/\_/ \__,_|_| \___|_| |_|\__,_|_| |_|\__,_|\__, |\___|_| + __/ | + |___/ + +""") +