mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
worked on downloads, magnets are next
This commit is contained in:
@@ -2,10 +2,9 @@ from bs4 import BeautifulSoup
|
|||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
|
from core.utils.network.jsonhandler import format_data
|
||||||
|
from core.utils.data.tracker import get_magnet_link
|
||||||
def get_Metadata():
|
from typing import Dict
|
||||||
return Metadata
|
|
||||||
|
|
||||||
cache = {
|
cache = {
|
||||||
"data": [],
|
"data": [],
|
||||||
@@ -74,13 +73,15 @@ def scrape_m0nkrus(query):
|
|||||||
|
|
||||||
return filtered_posts
|
return filtered_posts
|
||||||
|
|
||||||
|
def get_magnet(post: Dict):
|
||||||
|
_, post_links, _, _, _ = format_data([post])
|
||||||
|
return post_links[0]
|
||||||
|
|
||||||
Metadata = {
|
Metadata = {
|
||||||
"name" : "m0nkrus",
|
"name" : "m0nkrus",
|
||||||
"headers" : ["Post Title", "Author"],
|
"headers" : ["Post Title", "Author"],
|
||||||
"searchkey" : None,
|
|
||||||
"scrapeFunc" : scrape_m0nkrus,
|
"scrapeFunc" : scrape_m0nkrus,
|
||||||
"scrapeSearches" : True,
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
def init_m0nkrus():
|
def init_m0nkrus():
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import requests
|
import requests
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.utils.network.jsonhandler import split_data
|
from core.utils.network.jsonhandler import split_data, format_data
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
def scrape_rutracker(query):
|
def scrape_rutracker(query):
|
||||||
search = requests.get(f"{state.api_url}/search?q={query}")
|
search = requests.get(f"{state.api_url}/search?q={query}")
|
||||||
@@ -29,12 +29,17 @@ def scrape_rutracker(query):
|
|||||||
consoleLog("[core.data.scrapers.rutracker] No search Text, returning nothing")
|
consoleLog("[core.data.scrapers.rutracker] No search Text, returning nothing")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def get_magnet_link(post: Dict):
|
||||||
|
_, post_links, _, _, _ = format_data([post])
|
||||||
|
return post_links[0]
|
||||||
|
|
||||||
Metadata = {
|
Metadata = {
|
||||||
"name" : "rutracker",
|
"name" : "rutracker",
|
||||||
"headers" : ["Post Title", "Author", "Seeders", "Leechers"],
|
"headers" : ["Post Title", "Author", "Seeders", "Leechers"],
|
||||||
"searchkey" : None,
|
|
||||||
"scrapeFunc" : scrape_rutracker,
|
"scrapeFunc" : scrape_rutracker,
|
||||||
"scrapeSearches" : True,
|
"linkFunc" : get_magnet_link,
|
||||||
|
"isMagnet" : True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
|
|
||||||
|
import os
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from fuzzyfinder.main import fuzzyfinder
|
from fuzzyfinder.main import fuzzyfinder
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
import webbrowser
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
|
from core.utils.logging.logs import consoleLog
|
||||||
|
|
||||||
|
|
||||||
cache = {
|
cache = {
|
||||||
@@ -86,6 +89,21 @@ def scrape_steamrip_game_downloads(gamelink):
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def get_download_link(post: Dict):
|
||||||
|
url = post["link"]
|
||||||
|
links = scrape_steamrip_game_downloads(url)
|
||||||
|
best = ""
|
||||||
|
for link in links:
|
||||||
|
if link[0] != "h":
|
||||||
|
best = link
|
||||||
|
break
|
||||||
|
|
||||||
|
if links.index(best) < 2:
|
||||||
|
return best
|
||||||
|
else:
|
||||||
|
consoleLog("cant scrape this cuz of captcha... opening in the browser")
|
||||||
|
webbrowser.open(best)
|
||||||
|
return None
|
||||||
|
|
||||||
def filter_steamrip(query: str):
|
def filter_steamrip(query: str):
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ from bs4 import BeautifulSoup
|
|||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
|
||||||
def get_Metadata():
|
|
||||||
return Metadata
|
|
||||||
|
|
||||||
def scrape_uztracker(query):
|
def scrape_uztracker(query):
|
||||||
base_url="https://uztracker.net/"
|
base_url="https://uztracker.net/"
|
||||||
search_url = f"{base_url.rstrip('/')}/tracker.php?nm={query}"
|
search_url = f"{base_url.rstrip('/')}/tracker.php?nm={query}"
|
||||||
@@ -48,6 +46,9 @@ Metadata = {
|
|||||||
"scrapeFunc" : scrape_uztracker,
|
"scrapeFunc" : scrape_uztracker,
|
||||||
"scrapeSearches" : True,
|
"scrapeSearches" : True,
|
||||||
}
|
}
|
||||||
|
def get_magnet_link(post: Dict):
|
||||||
|
item = "https://uztracker.net/" + post["url"].lstrip("./")
|
||||||
|
return item
|
||||||
|
|
||||||
def init_uztracker():
|
def init_uztracker():
|
||||||
state.trackers.update({Metadata["name"] : Metadata})
|
state.trackers.update({Metadata["name"] : Metadata})
|
||||||
|
|||||||
@@ -187,6 +187,15 @@ def download_update(latest_version):
|
|||||||
def windowCloseHelper():
|
def windowCloseHelper():
|
||||||
QGuiApplication.quit()
|
QGuiApplication.quit()
|
||||||
|
|
||||||
|
class TrackerHoverDelegate(QStyledItemDelegate):
|
||||||
|
def paint(self, painter, option, index):
|
||||||
|
if index.row() == MainWindow._instance._tracker_hovered_row:
|
||||||
|
painter.save()
|
||||||
|
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||||
|
painter.restore()
|
||||||
|
super().paint(painter, option, index)
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||||
log_signal = Signal(str) # Thread-safe signal for logging
|
log_signal = Signal(str) # Thread-safe signal for logging
|
||||||
search_results_signal = Signal(list) # and searching
|
search_results_signal = Signal(list) # and searching
|
||||||
@@ -281,15 +290,13 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
model.dataChanged.disconnect()
|
model.dataChanged.disconnect()
|
||||||
state.trackertable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
|
state.trackertable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
|
||||||
|
|
||||||
class TrackerHoverDelegate(QStyledItemDelegate):
|
state.trackertable.setStyleSheet(_table_stylesheet("QTableWidget"))
|
||||||
def paint(self, painter, option, index):
|
|
||||||
if index.row() == MainWindow._instance._tracker_hovered_row:
|
|
||||||
painter.save()
|
|
||||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
|
||||||
painter.restore()
|
|
||||||
super().paint(painter, option, index)
|
|
||||||
|
|
||||||
|
|
||||||
|
state.trackertable.setItemDelegate(TrackerHoverDelegate(state.trackertable))
|
||||||
state.trackertable.viewport().installEventFilter(self)
|
state.trackertable.viewport().installEventFilter(self)
|
||||||
|
state.trackertable.setMouseTracking(True)
|
||||||
|
state.trackertable.viewport().setMouseTracking(True)
|
||||||
|
|
||||||
container = QWidget()
|
container = QWidget()
|
||||||
containerLayout = QVBoxLayout()
|
containerLayout = QVBoxLayout()
|
||||||
@@ -526,7 +533,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
#! FIX THIS
|
#! FIX THIS
|
||||||
|
|
||||||
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(state.trackertable.currentItem(), state.posts, state.trackers[state.currenttracker]["headers"]))))
|
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(state.trackertable.currentItem(), state.posts))))
|
||||||
|
|
||||||
container.setLayout(containerLayout)
|
container.setLayout(containerLayout)
|
||||||
self.setCentralWidget(container)
|
self.setCentralWidget(container)
|
||||||
@@ -695,6 +702,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.show_empty_results(False)
|
self.show_empty_results(False)
|
||||||
self.searchbar.setEnabled(True)
|
self.searchbar.setEnabled(True)
|
||||||
self.searchbar.setFocus()
|
self.searchbar.setFocus()
|
||||||
|
state.trackertable.setItemDelegate(TrackerHoverDelegate(state.trackertable))
|
||||||
|
state.trackertable.viewport().installEventFilter(self)
|
||||||
|
|
||||||
def update_image_overlay(self, new_image_path):
|
def update_image_overlay(self, new_image_path):
|
||||||
self.image = QImage(new_image_path)
|
self.image = QImage(new_image_path)
|
||||||
|
|||||||
@@ -1,31 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from core.utils.data.state import state
|
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.utils.network.jsonhandler import format_data
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_item_url(item, posts, post_titles): # softwarelist currentitem, post list (dict), post titles list
|
|
||||||
post_index = post_titles.index(item)
|
|
||||||
if 0 <= post_index < len(post_titles):
|
|
||||||
if state.tracker == "uztracker":
|
|
||||||
item = "https://uztracker.net/" + state.post_urls[post_index].lstrip("./")
|
|
||||||
consoleLog(f"Found post URL: {item}")
|
|
||||||
return item
|
|
||||||
if state.tracker == "rutracker":
|
|
||||||
item_dict = posts[post_index]
|
|
||||||
_, post_links, _, _, _ = format_data([item_dict])
|
|
||||||
consoleLog(f"Found post URL: {post_links[0]}")
|
|
||||||
return post_links[0]
|
|
||||||
if state.tracker == "m0nkrus":
|
|
||||||
item_dict = posts[post_index]
|
|
||||||
_, post_links, _, _, _,= format_data([item_dict])
|
|
||||||
consoleLog(f"Found post URL: {post_links[0]}")
|
|
||||||
return post_links[0]
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_magnet_link(post_url):
|
def get_magnet_link(post_url):
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
|
from PySide6.QtWidgets import QTableWidgetItem
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.utils.data.tracker import get_item_url
|
|
||||||
from core.utils.data.tracker import get_magnet_link
|
from core.utils.data.tracker import get_magnet_link
|
||||||
from core.network.libtorrent_wrapper import add_download
|
from core.network.libtorrent_wrapper import add_download
|
||||||
from core.utils.general.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
from core.utils.logging.logs import add_download_log
|
from core.utils.logging.logs import add_download_log
|
||||||
from core.network.libtorrent_int import add_seed
|
from core.network.libtorrent_int import add_seed
|
||||||
|
from core.utils.data.state import state
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
def download_selected(items, posts, post_titles):
|
def download_selected(items: list[QTableWidgetItem]):
|
||||||
if not items:
|
if not items:
|
||||||
consoleLog("No item selected for download.")
|
consoleLog("No item selected for download.")
|
||||||
return
|
return
|
||||||
@@ -17,10 +18,10 @@ def download_selected(items, posts, post_titles):
|
|||||||
if item.column() != 0:
|
if item.column() != 0:
|
||||||
continue
|
continue
|
||||||
text = item.text()
|
text = item.text()
|
||||||
if text and text not in seen:
|
if text != "" and text not in seen:
|
||||||
seen.add(text)
|
seen.add(text)
|
||||||
consoleLog(f"Downloading {text}")
|
consoleLog(f"Downloading {text}")
|
||||||
run_thread(threading.Thread(target=run_download, args=(text, posts, post_titles)))
|
run_thread(threading.Thread(target=run_download, args=(text, state.posts[item.row()])))
|
||||||
|
|
||||||
def run_download(item, posts, post_titles):
|
def run_download(item, posts, post_titles):
|
||||||
post_url = get_item_url(item, posts, post_titles)
|
post_url = get_item_url(item, posts, post_titles)
|
||||||
|
|||||||
Reference in New Issue
Block a user