mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
9e7607dd36
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.
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
from utils.logging.logs import consoleLog, add_download_log
|
|
from utils.data.state import state
|
|
from typing import Optional
|
|
|
|
|
|
from network.direct_download.handle import DirectDownloadHandle
|
|
from network.direct_download.utils import (
|
|
sanitize_filename,
|
|
extract_filename_from_url,
|
|
detect_filename_from_headers,
|
|
)
|
|
|
|
def add_direct_download(url: str, title: str, dl_path: Optional[str] = None, headers: Optional[dict] = None, single_threaded: bool = False):
|
|
|
|
if dl_path is None:
|
|
dl_path = state.download_path
|
|
|
|
if url in state.active_downloads:
|
|
consoleLog(f"Download already active: {title}")
|
|
return
|
|
|
|
filename = (
|
|
detect_filename_from_headers(url, DirectDownloadHandle.USER_AGENT)
|
|
or extract_filename_from_url(url)
|
|
or sanitize_filename(title) + ".zip"
|
|
)
|
|
|
|
handle = DirectDownloadHandle(url, filename, dl_path, headers, single_threaded)
|
|
state.active_downloads[url] = handle
|
|
add_download_log(title, url, "", False)
|
|
handle.start()
|
|
consoleLog(f"Started direct download: {filename}")
|