mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
improved debug output
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
from .aria2_integration import run_aria2p
|
from .aria2_integration import run_aria2p
|
||||||
|
from core.utils.data.state import state
|
||||||
|
|
||||||
def start_client():
|
def start_client():
|
||||||
global aria2
|
global aria2
|
||||||
aria2 = run_aria2p()
|
aria2 = run_aria2p()
|
||||||
|
if state.debug:
|
||||||
|
print("Started Aria2p")
|
||||||
|
|
||||||
def add_magnet(uri):
|
def add_magnet(uri):
|
||||||
aria2.add_magnet(uri)
|
aria2.add_magnet(uri)
|
||||||
|
if state.debug:
|
||||||
|
print("Magnet URI added to Aria2")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,21 @@ 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)
|
post_index = post_titles.index(item)
|
||||||
if 0 <= post_index < len(post_titles):
|
if 0 <= post_index < len(post_titles):
|
||||||
if state.tracker == "uztracker":
|
if state.tracker == "uztracker":
|
||||||
item = "https://uztracker.net/" + state.post_urls[post_index].lstrip("./")
|
item = "https://uztracker.net/" + state.post_urls[post_index].lstrip("./")
|
||||||
|
if state.debug:
|
||||||
|
print("Found post URL: ", item)
|
||||||
return item
|
return item
|
||||||
if state.tracker == "rutracker":
|
if state.tracker == "rutracker":
|
||||||
item_dict = posts[post_index]
|
item_dict = posts[post_index]
|
||||||
_, post_links, _ = format_data([item_dict])
|
_, post_links, _ = format_data([item_dict])
|
||||||
|
if state.debug:
|
||||||
|
print("Found post URL: ", post_links[0])
|
||||||
return post_links[0]
|
return post_links[0]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -22,6 +27,8 @@ def get_item_url(item, posts, post_titles): # oftwarelist currentitem, post list
|
|||||||
def get_magnet_link(post_url):
|
def get_magnet_link(post_url):
|
||||||
try:
|
try:
|
||||||
response = requests.get(post_url) # eventually impl. cloudscraper
|
response = requests.get(post_url) # eventually impl. cloudscraper
|
||||||
|
if state.debug:
|
||||||
|
print("Sent Request to retrieve Magnet Link...")
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
soup = BeautifulSoup(response.text, 'html.parser')
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||||||
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def kill_aria2server():
|
|||||||
if proc.name() == process:
|
if proc.name() == process:
|
||||||
proc.kill()
|
proc.kill()
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Killed Aria2c")
|
print(f"Killed Aria2c (PID {proc.pid})")
|
||||||
except psutil.NoSuchProcess:
|
except psutil.NoSuchProcess:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import threading
|
|||||||
def download_selected(item, posts, post_titles):
|
def download_selected(item, posts, post_titles):
|
||||||
if item is not None:
|
if item is not None:
|
||||||
if state.debug:
|
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)))
|
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user