mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8a1e72107 | |||
| 7c505f1402 | |||
| 55e4f86a39 | |||
| bd71b0e645 | |||
| 2a86e4b774 | |||
| d17b4bd44a | |||
| 10c935e852 | |||
| bd8320a26c | |||
| c99ce339e0 | |||
| 1822a150d7 | |||
| 7e5e3033e6 | |||
| 1cab671a13 | |||
| 5637e80657 | |||
| 2f78b812ba | |||
| 5af9e79ecc | |||
| 4dadc9ba50 | |||
| 719c4e86e8 | |||
| 999c8e9ba4 | |||
| 3f6889da56 | |||
| 69ac739be6 |
+15
-16
@@ -25,14 +25,14 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
artifact_name: SoftwareManager-dev-${{ github.sha }}-linux
|
||||
asset_name: SoftwareManager-dev-${{ github.sha }}-linux
|
||||
artifact_name: SoftwareManager-dev-linux
|
||||
asset_name: SoftwareManager-dev-linux
|
||||
- os: windows-latest
|
||||
artifact_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
||||
asset_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
||||
artifact_name: SoftwareManager-dev-windows.exe
|
||||
asset_name: SoftwareManager-dev-windows.exe
|
||||
- os: macos-latest
|
||||
artifact_name: SoftwareManager-dev-${{ github.sha }}-macos
|
||||
asset_name: SoftwareManager-dev-${{ github.sha }}-macos
|
||||
artifact_name: SoftwareManager-dev-macos
|
||||
asset_name: SoftwareManager-dev-macos
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@@ -121,23 +121,22 @@ jobs:
|
||||
- name: Prepare release files
|
||||
run: |
|
||||
mkdir -p release
|
||||
SHORT_SHA="${{ steps.version.outputs.short_sha }}"
|
||||
cp artifacts/ubuntu-latest-build/SoftwareManager-dev-*-linux release/SoftwareManager-dev-${SHORT_SHA}-linux
|
||||
cp artifacts/windows-latest-build/SoftwareManager-dev-*-windows.exe release/SoftwareManager-dev-${SHORT_SHA}-windows.exe
|
||||
cp artifacts/macos-latest-build/SoftwareManager-dev-*-macos release/SoftwareManager-dev-${SHORT_SHA}-macos
|
||||
chmod +x release/SoftwareManager-dev-*-linux release/SoftwareManager-dev-*-macos
|
||||
cp artifacts/ubuntu-latest-build/SoftwareManager-dev-linux release/SoftwareManager-dev-linux
|
||||
cp artifacts/windows-latest-build/SoftwareManager-dev-windows.exe release/SoftwareManager-dev-windows.exe
|
||||
cp artifacts/macos-latest-build/SoftwareManager-dev-macos release/SoftwareManager-dev-macos
|
||||
chmod +x release/SoftwareManager-dev-linux release/SoftwareManager-dev-macos
|
||||
ls -la release/
|
||||
|
||||
- name: Create Prerelease (Public)
|
||||
- name: Create Release (Public)
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.version }}
|
||||
name: ${{ steps.version.outputs.version }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
prerelease: false
|
||||
files: |
|
||||
release/SoftwareManager-dev-${{ steps.version.outputs.short_sha }}-linux
|
||||
release/SoftwareManager-dev-${{ steps.version.outputs.short_sha }}-windows.exe
|
||||
release/SoftwareManager-dev-${{ steps.version.outputs.short_sha }}-macos
|
||||
release/SoftwareManager-dev-linux
|
||||
release/SoftwareManager-dev-windows.exe
|
||||
release/SoftwareManager-dev-macos
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
|
||||
def scrape_monkrus_telegram(query):
|
||||
post = 100
|
||||
max_posts = 250
|
||||
posts: list[dict] = []
|
||||
added = set()
|
||||
|
||||
while post <= max_posts:
|
||||
url = f"https://t.me/s/real_monkrus/{post}"
|
||||
response = requests.get(url)
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
bubbles = soup.find_all("div", class_="tgme_widget_message_bubble")
|
||||
|
||||
if not bubbles:
|
||||
break
|
||||
|
||||
for bubble in bubbles:
|
||||
post_txt = bubble.find("div", class_="tgme_widget_message_text js-message_text")
|
||||
if not post_txt or not post_txt.b:
|
||||
continue
|
||||
|
||||
title = post_txt.b.text
|
||||
link = bubble.find("a", href=lambda x: x and x.startswith("https://uztracker.net"))
|
||||
|
||||
if query.lower() in title.lower() and link:
|
||||
post_url = link["href"]
|
||||
if post_url not in added:
|
||||
added.add(post_url)
|
||||
posts.append(dict(
|
||||
author="m0nkrus",
|
||||
id=len(posts) + 1,
|
||||
title=title,
|
||||
url=post_url
|
||||
))
|
||||
|
||||
post += 22
|
||||
|
||||
posts.reverse()
|
||||
return(posts)
|
||||
@@ -4,6 +4,8 @@ from core.utils.data.state import state
|
||||
|
||||
def scrape_rutracker(search_text):
|
||||
search = requests.get(f"{state.api_url}/search/{search_text}")
|
||||
if state.debug:
|
||||
print("Sent request to server")
|
||||
if search:
|
||||
try:
|
||||
return search.text
|
||||
|
||||
@@ -17,62 +17,56 @@ async def init_uztracker():
|
||||
up = True
|
||||
else:
|
||||
up = False
|
||||
print(f"Uztracker seems down, status code: {response.status_code}")
|
||||
if state.debug:
|
||||
print(f"Uztracker seems down, status code: {response.status_code}")
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"\nRequest Exception on {url_uztracker}:")
|
||||
print(e)
|
||||
print("\nIs the Site down?")
|
||||
if state.debug:
|
||||
print(f"\nRequest Exception on {url_uztracker}:")
|
||||
print(e)
|
||||
print("\nIs the Site down?")
|
||||
up = False
|
||||
|
||||
asyncio.run(init_uztracker())
|
||||
|
||||
async def scrape_uztracker(search, max_results=450):
|
||||
def scrape_uztracker(search):
|
||||
if up:
|
||||
search_url = url_uztracker + search
|
||||
if state.debug:
|
||||
print(search_url)
|
||||
result = False
|
||||
global results
|
||||
global resulttitles
|
||||
results = []
|
||||
results = []
|
||||
resulttitles = []
|
||||
|
||||
per_page = 50
|
||||
try:
|
||||
resultCount = 0
|
||||
response = requests.get(search_url)
|
||||
response.raise_for_status()
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
links = soup.find_all('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic'))
|
||||
for link in links:
|
||||
if link.b:
|
||||
resultCount += 1
|
||||
results.append(link['href'])
|
||||
resulttitles.append(link.b.text)
|
||||
result = True
|
||||
|
||||
for start in range(0, max_results, per_page):
|
||||
search_url = url_uztracker + search + f"&start={start}"
|
||||
if state.debug:
|
||||
print(search_url)
|
||||
if result:
|
||||
return resulttitles, results
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.get(search_url) as response:
|
||||
response.raise_for_status()
|
||||
text = await response.text()
|
||||
soup = BeautifulSoup(text, 'html.parser')
|
||||
links = soup.find_all('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic'))
|
||||
resultCount = 0
|
||||
for link in links:
|
||||
if link.b:
|
||||
resultCount += 1
|
||||
results.append(link['href'])
|
||||
resulttitles.append(link.b.text)
|
||||
result = True
|
||||
|
||||
if resultCount == 0:
|
||||
# add popup in gui for no result
|
||||
break
|
||||
|
||||
except aiohttp.ClientError as e:
|
||||
if result:
|
||||
print(f"Failed to fetch {search_url}: {e}")
|
||||
return None
|
||||
if not result:
|
||||
# add popup in gui for no result
|
||||
return None
|
||||
|
||||
else:
|
||||
except requests.RequestException as e:
|
||||
if result and state.debug:
|
||||
print(f"Failed to fetch {search_url}: {e}")
|
||||
return None
|
||||
else:
|
||||
if state.debug:
|
||||
print("Error: Uztracker down")
|
||||
return None, None
|
||||
|
||||
if not results:
|
||||
return None, None
|
||||
|
||||
return resulttitles, results
|
||||
return None, None
|
||||
|
||||
def get_post_title(post_url):
|
||||
if up:
|
||||
@@ -85,7 +79,8 @@ def get_post_title(post_url):
|
||||
if state.debug:
|
||||
print("Program not found")
|
||||
else:
|
||||
print("Error: Uztracker down")
|
||||
if state.debug:
|
||||
print("Error: Uztracker down")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +114,6 @@ def settings_dialog(self):
|
||||
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.text(), download_path.text(), speed_limit.value()))
|
||||
|
||||
cancel_btn.clicked.connect(dialog.reject)
|
||||
print(thread_box.value())
|
||||
layout.addWidget(cancel_btn)
|
||||
layout.addWidget(save_btn)
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
toolbar.setLayoutDirection(Qt.RightToLeft)
|
||||
|
||||
self.tracker_list = QComboBox()
|
||||
self.tracker_list.addItems(["rutracker", "uztracker"])
|
||||
self.tracker_list.addItems(["rutracker", "uztracker", "m0nkrus"])
|
||||
self.tracker_list.activated.connect(self.set_tracker)
|
||||
|
||||
|
||||
|
||||
@@ -1,33 +1,45 @@
|
||||
import asyncio
|
||||
from core.data.scrapers.uztracker import scrape_uztracker
|
||||
from core.data.scrapers.rutracker import scrape_rutracker
|
||||
from core.data.scrapers.monkrus import scrape_monkrus_telegram
|
||||
from core.utils.network.jsonhandler import split_data, format_data
|
||||
from core.utils.data.state import state
|
||||
|
||||
def return_pressed(self):
|
||||
search_text = self.searchbar.text()
|
||||
if search_text == "":
|
||||
if state.debug:
|
||||
print("Error: Can't search for nothing")
|
||||
return
|
||||
search_text = self.searchbar.text()
|
||||
if search_text == "":
|
||||
if state.debug:
|
||||
print("User searched for:", search_text)
|
||||
if state.tracker == "uztracker":
|
||||
response = asyncio.run(scrape_uztracker(search_text))
|
||||
if state.tracker == "rutracker":
|
||||
response = scrape_rutracker(search_text)
|
||||
print("Error: Can't search for nothing")
|
||||
return
|
||||
if state.debug:
|
||||
print("User searched for:", search_text)
|
||||
|
||||
if state.tracker == "uztracker":
|
||||
response = scrape_uztracker(search_text)
|
||||
if response:
|
||||
if state.tracker == "uztracker":
|
||||
state.post_titles, state.post_urls, = response
|
||||
state.post_titles, state.post_urls = response
|
||||
self.softwareList.clear()
|
||||
if state.post_titles and len(state.post_titles) > 0:
|
||||
self.softwareList.addItems(state.post_titles)
|
||||
self.show_empty_results(False)
|
||||
self.post_author_list.clear()
|
||||
else:
|
||||
if state.debug:
|
||||
print(f"No Results for {search_text}")
|
||||
self.softwareList.clear()
|
||||
if state.post_titles:
|
||||
self.softwareList.addItems(state.post_titles)
|
||||
self.post_author_list.addItems(state.post_author)
|
||||
if state.tracker == "rutracker":
|
||||
_, state.posts, _, _, cached = split_data(response)
|
||||
self.show_empty_results(True)
|
||||
else:
|
||||
if state.debug:
|
||||
print(f"No response from uztracker")
|
||||
self.softwareList.clear()
|
||||
self.show_empty_results(True)
|
||||
|
||||
elif state.tracker == "rutracker":
|
||||
response = scrape_rutracker(search_text)
|
||||
if response:
|
||||
_, state.posts, _, _, cached = split_data(response)
|
||||
if state.posts == []:
|
||||
if state.debug:
|
||||
print(f"No Results found for \"{search_text}\"")
|
||||
print(f"No Results for {search_text}")
|
||||
self.softwareList.clear()
|
||||
self.show_empty_results(True)
|
||||
else:
|
||||
@@ -38,5 +50,25 @@ def return_pressed(self):
|
||||
self.softwareList.clear()
|
||||
self.softwareList.addItems(state.post_titles)
|
||||
if state.debug == True:
|
||||
print(f"Cached: {cached}")
|
||||
print(f"Response Cached: {cached}")
|
||||
else:
|
||||
if state.debug:
|
||||
print(f"No response from rutracker")
|
||||
self.softwareList.clear()
|
||||
self.show_empty_results(True)
|
||||
|
||||
elif state.tracker == "m0nkrus":
|
||||
state.posts = scrape_monkrus_telegram(search_text)
|
||||
|
||||
if state.posts == []:
|
||||
if state.debug:
|
||||
print(f"No Results for {search_text}")
|
||||
self.softwareList.clear()
|
||||
self.show_empty_results(True)
|
||||
else:
|
||||
state.post_titles, _, state.post_author = format_data(state.posts)
|
||||
self.show_empty_results(False)
|
||||
self.post_author_list.clear()
|
||||
self.post_author_list.addItems(state.post_author)
|
||||
self.softwareList.clear()
|
||||
self.softwareList.addItems(state.post_titles)
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
from .aria2_integration import run_aria2p
|
||||
from core.utils.data.state import state
|
||||
|
||||
def start_client():
|
||||
global aria2
|
||||
aria2 = run_aria2p()
|
||||
if state.debug:
|
||||
print("Started Aria2p")
|
||||
|
||||
def add_magnet(uri):
|
||||
aria2.add_magnet(uri)
|
||||
if state.debug:
|
||||
print("Magnet URI added to Aria2")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,16 +5,27 @@ from core.utils.network.jsonhandler import format_data
|
||||
|
||||
|
||||
|
||||
def get_item_url(item, posts, post_titles): # oftwarelist currentitem, post list (dict), post titles list
|
||||
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("./")
|
||||
if state.debug:
|
||||
print("Found post URL: ", item)
|
||||
return item
|
||||
if state.tracker == "rutracker":
|
||||
item_dict = posts[post_index]
|
||||
_, post_links, _ = format_data([item_dict])
|
||||
if state.debug:
|
||||
print("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])
|
||||
if state.debug:
|
||||
print("Found post URL: ", post_links[0])
|
||||
return post_links[0]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -22,6 +33,8 @@ def get_item_url(item, posts, post_titles): # oftwarelist currentitem, post list
|
||||
def get_magnet_link(post_url):
|
||||
try:
|
||||
response = requests.get(post_url) # eventually impl. cloudscraper
|
||||
if state.debug:
|
||||
print("Sent Request to retrieve Magnet Link...")
|
||||
response.raise_for_status()
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
||||
|
||||
@@ -22,7 +22,7 @@ def kill_aria2server():
|
||||
if proc.name() == process:
|
||||
proc.kill()
|
||||
if state.debug:
|
||||
print("Killed Aria2c")
|
||||
print(f"Killed Aria2c (PID {proc.pid})")
|
||||
except psutil.NoSuchProcess:
|
||||
pass
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import threading
|
||||
def download_selected(item, posts, post_titles):
|
||||
if item is not None:
|
||||
if state.debug:
|
||||
print(f"network {item.text()}")
|
||||
print(f"Downloading {item.text()}")
|
||||
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
||||
|
||||
else:
|
||||
|
||||
@@ -10,11 +10,14 @@ import qdarktheme
|
||||
import darkdetect
|
||||
import threading
|
||||
import signal
|
||||
import atexit
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
# Debug Output
|
||||
state.debug = True
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--debug", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
def run_gui():
|
||||
@@ -36,6 +39,7 @@ def keyboardinterrupthandler(signum, frame):
|
||||
|
||||
if __name__ == "__main__":
|
||||
read_config()
|
||||
state.debug = args.debug # override of read_config
|
||||
if state.debug:
|
||||
print("Starting Aria2 Server")
|
||||
state.aria2process = run_aria2server()
|
||||
|
||||
Reference in New Issue
Block a user