From 9a28afcb48e213b04a2c10cf0712fd3594e823b5 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 5 Dec 2022 19:46:48 +0000 Subject: [PATCH] custom mediaplayer-toggle cursor --- copyparty/__main__.py | 1 + copyparty/httpcli.py | 9 +++++++++ copyparty/util.py | 1 + 3 files changed, 11 insertions(+) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 5be22b7c..3ecdfea6 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -843,6 +843,7 @@ def run_argparse( ap2.add_argument("--theme", metavar="NUM", type=int, default=0, help="default theme to use") ap2.add_argument("--themes", metavar="NUM", type=int, default=8, help="number of themes installed") ap2.add_argument("--favico", metavar="TXT", type=u, default="c 000 none" if retry else "🎉 000 none", help="\033[33mfavicon-text\033[0m [ \033[33mforeground\033[0m [ \033[33mbackground\033[0m ] ], set blank to disable") + ap2.add_argument("--mpmc", metavar="URL", type=u, default="", help="change the mediaplayer-toggle mouse cursor; URL to a folder with {2..5}.png inside (or disable with [\033[32m.\033[0m])") ap2.add_argument("--js-browser", metavar="L", type=u, help="URL to additional JS to include") ap2.add_argument("--css-browser", metavar="L", type=u, help="URL to additional CSS to include") ap2.add_argument("--html-head", metavar="TXT", type=u, default="", help="text to append to the of all HTML pages") diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index a4c9e66b..0b77e1d9 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -641,6 +641,15 @@ class HttpCli(object): if self.vpath.startswith(".cpr/ssdp"): return self.conn.hsrv.ssdp.reply(self) + if self.vpath.startswith(".cpr/dd/") and self.args.mpmc: + if self.args.mpmc == ".": + raise Pebkac(404) + + loc = self.args.mpmc.rstrip("/") + self.vpath[self.vpath.rfind("/") :] + h = {"Location": loc, "Cache-Control": "max-age=39"} + self.reply(b"", 301, headers=h) + return True + static_path = os.path.join(self.E.mod, "web/", self.vpath[5:]) return self.tx_file(static_path) diff --git a/copyparty/util.py b/copyparty/util.py index e4fd4dd3..4da1946b 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -148,6 +148,7 @@ HTTPCODE = { 204: "No Content", 206: "Partial Content", 207: "Multi-Status", + 301: "Moved Permanently", 302: "Found", 304: "Not Modified", 400: "Bad Request",