mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
refactor: get_magnet to get_download_link
Rename scraper method get_magnet -> get_download_link in monkrus, rutracker and uztracker. Update downloader code to call .get_download_link and use the .is_magnet flag on tracker objects (replace dict access). Switch direct_download package imports to absolute paths and perform a small import reorder in direct_download/utils.py. These changes unify the download API and adapt call sites to the new tracker interface.
This commit is contained in:
@@ -74,5 +74,5 @@ class MonkrusScraper:
|
|||||||
|
|
||||||
return filtered_posts
|
return filtered_posts
|
||||||
|
|
||||||
def get_magnet(self, post: Dict):
|
def get_download_link(self, post: Dict):
|
||||||
return get_magnet_link(post["url"])
|
return get_magnet_link(post["url"])
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class RutrackerScraper:
|
|||||||
consoleLog("No response from server, returning nothing")
|
consoleLog("No response from server, returning nothing")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_magnet(self, post: Dict):
|
def get_download_link(self, post: Dict):
|
||||||
_, post_links, _, _, _ = format_data([post])
|
_, post_links, _, _, _ = format_data([post])
|
||||||
return get_magnet_link(post_links[0])
|
return get_magnet_link(post_links[0])
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,6 @@ class UztrackerScraper:
|
|||||||
consoleLog(f"Failed to fetch {search_url}: {e}")
|
consoleLog(f"Failed to fetch {search_url}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_magnet(self, post: Dict):
|
def get_download_link(self, post: Dict):
|
||||||
return get_magnet_link(post["url"])
|
return get_magnet_link(post["url"])
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ from utils.data.state import state
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
from .handle import DirectDownloadHandle
|
from network.direct_download.handle import DirectDownloadHandle
|
||||||
from .utils import (
|
from network.direct_download.utils import (
|
||||||
sanitize_filename,
|
sanitize_filename,
|
||||||
extract_filename_from_url,
|
extract_filename_from_url,
|
||||||
detect_filename_from_headers,
|
detect_filename_from_headers,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from utils.logging.logs import consoleLog
|
|
||||||
from urllib.parse import urlparse, unquote
|
from urllib.parse import urlparse, unquote
|
||||||
|
from utils.logging.logs import consoleLog
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ def download_selected(items: list[QTableWidgetItem]):
|
|||||||
run_thread(threading.Thread(target=run_download, args=(post,)))
|
run_thread(threading.Thread(target=run_download, args=(post,)))
|
||||||
|
|
||||||
def run_download(post, headers: Optional[dict] = None):
|
def run_download(post, headers: Optional[dict] = None):
|
||||||
linkfunc = state.trackers[state.currenttracker]["linkFunc"]
|
link_method = state.trackers[state.currenttracker].get_download_link
|
||||||
ismagnet = state.trackers[state.currenttracker]["isMagnet"]
|
ismagnet = state.trackers[state.currenttracker].is_magnet
|
||||||
result = linkfunc(post)
|
result = link_method(post)
|
||||||
|
|
||||||
if ismagnet:
|
if ismagnet:
|
||||||
link = result
|
link = result
|
||||||
|
|||||||
Reference in New Issue
Block a user