Advertisement
BlastFM

garbage mk2

Apr 26th, 2022
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import asyncio
  2. import websockets
  3.  
  4. URI = "-"
  5. TOKEN = "-"
  6. data = []
  7.  
  8. async def main():
  9.     async with websockets.connect(URI) as socket:
  10.         msg = TOKEN
  11.         await socket.send(msg)
  12.         await listen(socket)
  13.    
  14.  
  15. async def listen(socket):
  16.     msg = await socket.recv()
  17.     if msg["kind"]!="data": ##todo actual conversion - i recieve a string lmao
  18.         output = {"root":data}
  19.         # save to a file
  20.         await print(output)
  21.         await socket.stop()
  22.     else:
  23.         data.append(msg["payload"])
  24.  
  25. asyncio.run(main())
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement