update refactoring and add new features

This commit is contained in:
2026-07-24 20:55:58 -07:00
parent 7f12bc7f40
commit 03fbbbcf28
69 changed files with 16332 additions and 17600 deletions
+20 -3
View File
@@ -243,9 +243,11 @@ class _LineFilterStream(io.TextIOBase):
def _suppress_aioslsk_noise() -> Any:
"""Temporarily suppress known aioslsk noise printed to stdout/stderr.
Opt out by setting DOWNLOW_SOULSEEK_VERBOSE=1.
Opt out by setting DOWNLOAD_SOULSEEK_VERBOSE=1.
Note: The old env var name DOWNLOW_SOULSEEK_VERBOSE (typo) is deprecated.
"""
if os.environ.get("DOWNLOW_SOULSEEK_VERBOSE"):
if os.environ.get("DOWNLOAD_SOULSEEK_VERBOSE") or os.environ.get("DOWNLOW_SOULSEEK_VERBOSE"):
yield
return
@@ -404,7 +406,7 @@ class Soulseek(Provider):
)
except RuntimeError:
# If we're already inside an event loop (e.g., TUI), fall back to a
# If we're already inside an event loop, fall back to a
# dedicated loop in this thread.
loop = asyncio.new_event_loop()
try:
@@ -568,6 +570,21 @@ class Soulseek(Provider):
timeout=9.0,
limit=limit)
)
except RuntimeError:
loop = asyncio.new_event_loop()
try:
asyncio.set_event_loop(loop)
flat_results, search_summary = loop.run_until_complete(
self.perform_search(query, timeout=9.0, limit=limit)
)
finally:
try:
loop.run_until_complete(loop.shutdown_asyncgens())
except Exception:
pass
loop.close()
try:
if not flat_results:
return []