jh
This commit is contained in:
@@ -286,7 +286,7 @@ class Soulseek(Provider):
|
||||
# NOTE: These defaults preserve existing behavior.
|
||||
USERNAME = "asjhkjljhkjfdsd334"
|
||||
PASSWORD = "khhhg"
|
||||
DOWNLOAD_DIR = "./downloads"
|
||||
DOWNLOAD_DIR = None
|
||||
MAX_WAIT_TRANSFER = 1200
|
||||
|
||||
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
||||
@@ -325,13 +325,17 @@ class Soulseek(Provider):
|
||||
)
|
||||
return None
|
||||
|
||||
# Use tempfile directory as default if '.' or generic placeholder was passed
|
||||
# by a caller that didn't know better.
|
||||
target_dir = Path(output_dir)
|
||||
if str(target_dir) == "." or str(target_dir) == "downloads":
|
||||
# Use tempfile directory as default if generic path elements were passed or None.
|
||||
if output_dir is None:
|
||||
import tempfile
|
||||
target_dir = Path(tempfile.gettempdir()) / "Medios" / "Soulseek"
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
else:
|
||||
target_dir = Path(output_dir)
|
||||
if str(target_dir) in (".", "downloads", "Downloads"):
|
||||
import tempfile
|
||||
target_dir = Path(tempfile.gettempdir()) / "Medios" / "Soulseek"
|
||||
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# This cmdlet stack is synchronous; use asyncio.run for clarity.
|
||||
return asyncio.run(
|
||||
@@ -348,12 +352,22 @@ class Soulseek(Provider):
|
||||
# dedicated loop in this thread.
|
||||
loop = asyncio.new_event_loop()
|
||||
try:
|
||||
# Re-resolve target_dir inside rescue block just in case
|
||||
if output_dir is None:
|
||||
import tempfile
|
||||
target_dir = Path(tempfile.gettempdir()) / "Medios" / "Soulseek"
|
||||
else:
|
||||
target_dir = Path(output_dir)
|
||||
if str(target_dir) in (".", "downloads", "Downloads"):
|
||||
import tempfile
|
||||
target_dir = Path(tempfile.gettempdir()) / "Medios" / "Soulseek"
|
||||
|
||||
asyncio.set_event_loop(loop)
|
||||
return loop.run_until_complete(
|
||||
download_soulseek_file(
|
||||
username=username,
|
||||
filename=filename,
|
||||
output_dir=output_dir,
|
||||
output_dir=target_dir,
|
||||
timeout=self.MAX_WAIT_TRANSFER,
|
||||
)
|
||||
)
|
||||
@@ -642,7 +656,7 @@ class Soulseek(Provider):
|
||||
async def download_soulseek_file(
|
||||
username: str,
|
||||
filename: str,
|
||||
output_dir: Path = Path("./downloads"),
|
||||
output_dir: Optional[Path] = None,
|
||||
timeout: int = 1200,
|
||||
*,
|
||||
client_username: Optional[str] = None,
|
||||
@@ -656,6 +670,10 @@ async def download_soulseek_file(
|
||||
from aioslsk.transfer.model import Transfer, TransferDirection
|
||||
from aioslsk.transfer.state import TransferState
|
||||
|
||||
if output_dir is None:
|
||||
import tempfile
|
||||
output_dir = Path(tempfile.gettempdir()) / "Medios" / "Soulseek"
|
||||
|
||||
output_dir = Path(output_dir)
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user