Created
September 25, 2025 05:57
-
-
Save redraw/de066dc881e66eff11a6e74e819b2165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import asyncio | |
import argparse | |
from aioslsk.client import SoulSeekClient | |
from aioslsk.settings import Settings, CredentialsSettings | |
from aioslsk.events import SearchRequestReceivedEvent, SearchRequestSentEvent | |
async def main(): | |
ap = argparse.ArgumentParser(description="Dump distributed search requests (Soulseek)") | |
ap.add_argument("-u", "--username", required=True) | |
ap.add_argument("-p", "--password", required=True) | |
args = ap.parse_args() | |
client = SoulSeekClient(Settings( | |
credentials=CredentialsSettings(username=args.username, password=args.password) | |
)) | |
async def on_recv(ev: SearchRequestReceivedEvent): | |
# ev.username, ev.query, ev.result_count (según versión) | |
u = getattr(ev, "username", None) | |
q = getattr(ev, "query", None) | |
n = getattr(ev, "result_count", None) | |
print(f"[D-RECV] user={u!r} query={q!r} results={n}") | |
async def on_sent(ev: SearchRequestSentEvent): | |
# útil para correlacionar lo que tú enviaste | |
q = getattr(ev, "query", None) | |
print(f"[D-SENT] query={getattr(q, 'query', q)!r}") | |
# Registro correcto: (clase_de_evento, callback) | |
client.events.register(SearchRequestReceivedEvent, on_recv) | |
client.events.register(SearchRequestSentEvent, on_sent) | |
await client.start() | |
await client.login() | |
# El cliente se une solo a la red distribuida; no hace falta API privada | |
await client.run_until_stopped() | |
if __name__ == "__main__": | |
asyncio.run(main()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment