From ea50300c1479c3dacfde0c2b4709b53aebb59424 Mon Sep 17 00:00:00 2001 From: Soap Date: Wed, 8 Oct 2025 00:03:11 +0000 Subject: [PATCH] Added support for Magnets! --- copyparty/cfg/hooks/ytdlp.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/copyparty/cfg/hooks/ytdlp.py b/copyparty/cfg/hooks/ytdlp.py index dcbc235..b075cbd 100644 --- a/copyparty/cfg/hooks/ytdlp.py +++ b/copyparty/cfg/hooks/ytdlp.py @@ -52,12 +52,11 @@ while you're in the /inc folder (or any folder below there) def main(): inf = json.loads(sys.argv[1]) url = inf["txt"] - if "://" not in url: + if "://" not in url and url[:6] != 'magnet': url = "https://" + url - - proto = url.split("://")[0].lower() - if proto not in ("http", "https", "ftp", "ftps"): - raise Exception("bad proto {}".format(proto)) + proto = url.split("://")[0].lower() + if proto not in ("http", "https", "ftp", "ftps"): + raise Exception("bad proto {}".format(proto)) os.chdir(inf["ap"]) @@ -73,13 +72,16 @@ def main(): "--downloader-args", "-j 16 -x 8 -s 16 -k 1M", url ] + print(url[:6]) + if url[:6] == 'magnet': + cmd = [cmd[4]] + [cmd[7]] - if '.' in (name[-3], name[-4]) and name[-3:] != 'php': - cmd += ["-o", name] + else: + if '.' in (name[-3], name[-4]) and name[-3:] != 'php': + cmd += ["-o", name] print(" ".join(cmd) + "\n", end="") - try: result = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE, text=True) print("STDOUT:\n" + result.stdout)