mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
added rutracker as option. check full message
IMPORTANT: doesnt have error handling fo no result will add a gui option in the future
This commit is contained in:
@@ -103,6 +103,7 @@ def get_magnet_link(post_url, debug):
|
||||
# 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:"?
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
|
||||
@@ -116,3 +117,5 @@ def get_item_index(item, list, listlinks, debug):
|
||||
selected_magnet = get_magnet_link(selected, debug)
|
||||
start_client()
|
||||
add_magnet(selected_magnet)
|
||||
=======
|
||||
>>>>>>> af99e99 (added rutracker as option. check full message)
|
||||
|
||||
+74
-5
@@ -3,17 +3,30 @@ from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QLineEdit, QPushButton, QWidget, QVBoxLayout, QListWidget, QToolBar, QDialogButtonBox, QRadioButton, QGroupBox, QDialog, QVBoxLayout, QLabel, QHBoxLayout
|
||||
from PySide6.QtGui import QIcon, QAction
|
||||
import darkdetect
|
||||
import requests
|
||||
from core.scraping.uztracker_scraper import scrape_uztracker
|
||||
from core.scraping.uztracker_scraper import get_item_index
|
||||
|
||||
|
||||
|
||||
def state_debug(setting):
|
||||
global debug
|
||||
if setting is True:
|
||||
debug = True
|
||||
else:
|
||||
debug = False
|
||||
|
||||
def choose_tracker():
|
||||
global rutracker
|
||||
choice = input("use rutracker? (y/n): ")
|
||||
print(choice)
|
||||
if choice.lower() == 'y':
|
||||
print("Using rutracker...")
|
||||
rutracker = True
|
||||
else:
|
||||
print("Using uztracker...")
|
||||
rutracker = False
|
||||
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
def __init__(self):
|
||||
global settings_action
|
||||
@@ -102,13 +115,29 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
|
||||
def download_selected(self):
|
||||
item = self.softwareList.currentItem()
|
||||
<<<<<<< HEAD
|
||||
if item is not None:
|
||||
if debug:
|
||||
print(f"Downloading {self.softwareList.currentItem().text()}")
|
||||
get_item_index(self.softwareList.currentItem().text(), self.postnames, self.postlinks, debug)
|
||||
=======
|
||||
if rutracker == True:
|
||||
if item is not None:
|
||||
if debug:
|
||||
print(f"Downloading {self.softwareList.currentItem().text()}")
|
||||
self.get_item_index(self.softwareList.currentItem().text(), self.postnames_rutracker, self.postlinks_rutracker, debug)
|
||||
else:
|
||||
if debug:
|
||||
print("No item selected for download.")
|
||||
>>>>>>> af99e99 (added rutracker as option. check full message)
|
||||
else:
|
||||
if debug:
|
||||
print("No item selected for download.")
|
||||
if item is not None:
|
||||
if debug:
|
||||
print(f"Downloading {self.softwareList.currentItem().text()}")
|
||||
self.get_item_index(self.softwareList.currentItem().text(), self.postnames_uztracker, self.postlinks_uztracker, debug)
|
||||
else:
|
||||
if debug:
|
||||
print("No item selected for download.")
|
||||
# add gui notification for no item selected
|
||||
|
||||
|
||||
@@ -117,10 +146,10 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
if item is not None:
|
||||
return item.text()
|
||||
return ""
|
||||
|
||||
|
||||
|
||||
|
||||
def return_pressed(self):
|
||||
<<<<<<< HEAD
|
||||
search_text = self.searchbar.text()
|
||||
if debug:
|
||||
print("User searched for:", search_text)
|
||||
@@ -138,3 +167,43 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
|
||||
|
||||
|
||||
=======
|
||||
if rutracker == True:
|
||||
global postnames
|
||||
global postlinks
|
||||
search_text = self.searchbar.text()
|
||||
search = requests.get(f"https://pizzasucht.net/search/{search_text}")
|
||||
self.softwareList.clear()
|
||||
data = search.json()
|
||||
self.postnames_rutracker = data["titles"]
|
||||
for self.postnames_rutracker in data["titles"]:
|
||||
self.softwareList.addItem(self.postnames_rutracker)
|
||||
self.postnames_rutracker = data["titles"]
|
||||
self.postlinks_rutracker = data["links"]
|
||||
else:
|
||||
search_text = self.searchbar.text()
|
||||
if debug:
|
||||
print("User searched for:", search_text)
|
||||
|
||||
response = scrape_uztracker(search_text, debug)
|
||||
if response:
|
||||
self.postnames_uztracker, self.postlinks_uztracker = response
|
||||
self.softwareList.clear()
|
||||
if self.postnames_uztracker:
|
||||
self.softwareList.addItems(self.postnames_uztracker)
|
||||
elif debug:
|
||||
print(f"No Results found for \"{search_text}\"")
|
||||
|
||||
def get_item_index(self, 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.
|
||||
if rutracker == True:
|
||||
selected = listlinks[position]
|
||||
else:
|
||||
selected = "https://uztracker.net/" + listlinks[position].lstrip("./")
|
||||
if debug:
|
||||
print("Selected URL: ", selected)
|
||||
selected_magnet = get_magnet_link(selected, debug)
|
||||
start_client()
|
||||
add_magnet(selected_magnet)
|
||||
>>>>>>> af99e99 (added rutracker as option. check full message)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from core.ui.gui import MainWindow
|
||||
from core.ui.gui import state_debug
|
||||
from core.ui.gui import choose_tracker
|
||||
from PySide6 import QtWidgets
|
||||
import qdarktheme
|
||||
import darkdetect
|
||||
@@ -9,6 +10,7 @@ debug = True
|
||||
|
||||
def run_gui():
|
||||
state_debug(debug)
|
||||
choose_tracker()
|
||||
app = QtWidgets.QApplication([])
|
||||
if darkdetect.isDark:
|
||||
app.setStyleSheet(qdarktheme.load_stylesheet("dark"))
|
||||
@@ -18,6 +20,5 @@ def run_gui():
|
||||
widget.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_gui()
|
||||
|
||||
Reference in New Issue
Block a user