fix(mpv-pip): Accept newline-separated targets

This commit is contained in:
2026-09-05 09:29:17 +02:00
parent 5216362be7
commit 8c78f79720
+17 -11
View File
@@ -5,20 +5,26 @@ MPV=/opt/homebrew/bin/mpv
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
echo "Usage: $(basename "$0") <file|url> [file|url ...]" >&2 echo "Usage: $(basename "$0") <file|url> [file|url ...]" >&2
echo " $(basename "$0") mpv://open?url=<url-encoded target>" >&2
exit 1 exit 1
fi fi
TARGETS=() IFS=$'\n' read -d '' -r -a TARGETS < <(python3 -c '
for arg in "$@"; do
if [[ "$arg" == mpv://* ]]; then
arg=$(python3 -c '
import sys, urllib.parse as u import sys, urllib.parse as u
q = u.parse_qs(u.urlparse(sys.argv[1]).query)
print(q["url"][0]) for arg in sys.argv[1:]:
' "$arg") for line in arg.splitlines():
fi line = line.strip()
TARGETS+=("$arg") if not line:
done continue
if line.startswith("mpv://"):
try:
parsed = u.urlparse(line)
line = u.parse_qs(parsed.query)["url"][0]
except (KeyError, IndexError):
pass
print(line)
' "$@") || true
[[ ${#TARGETS[@]} -eq 0 ]] && exit 1
"$MPV" --ontop --on-all-workspaces --volume=0 "${TARGETS[@]}" & "$MPV" --ontop --on-all-workspaces --volume=0 "${TARGETS[@]}" &