# aqget, a proof of concept client for Aquarius # Copyright 2020 Hannu Hartikainen. GPLv3. import socket import sys import urllib.parse # monkey-patch aquarius:// support in urljoin :shrug: urllib.parse.uses_relative.append("aquarius") urllib.parse.uses_netloc.append("aquarius") def download(url_str): url = urllib.parse.urlparse(url_str) if url.scheme != "aquarius": print("only aquarius:// is supported") addr = (url.hostname, url.port or 1970) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(bytes(url_str + "\r\n", "utf-8"), addr) sock.settimeout(5) while True: try: data = sock.recv(4096) except socket.timeout: break if not data: break print(data.decode("utf-8"), end="", flush=True) if __name__ == '__main__': download(sys.argv[1])