From 99b4abc9b126ec7465c83d4717a621239feac48d Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Tue, 20 Sep 2022 15:53:09 +0200 Subject: [PATCH] add youtube-dl audo and video delegator --- local/bin/delegator | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/local/bin/delegator b/local/bin/delegator index 3ac08dc..d9bcb81 100755 --- a/local/bin/delegator +++ b/local/bin/delegator @@ -34,6 +34,8 @@ clipmenu yubikey emoji spotify-title +youtube-dl +audio-dl HERE )" @@ -87,6 +89,24 @@ case "$choice" in inject "${choice##* }" ;; 'spotify-title') - inject "$(curl -L "$(xclip -o)" | sed -n 's@.*\(.*\) - song by \(.*\) | Spotify.*@\1 - \2@p')" + inject "$(curl -L "$(xclip -o)" | sed -n 's@.*\(.*\) - song \(and lyrics \)\?by \(.*\) | Spotify.*@\1 - \3@p')" + ;; +'youtube-dl') + d="$(mktemp -d)" + trap "rm -r '$d'" EXIT KILL + cd "$d" + yt-dlp "$(xclip -o)" + if mplayer -v >/dev/null; then + exec st mplayer * + else + exec st mpv * + fi + ;; +'audio-dl') + d="$(mktemp -d)" + trap "rm -r '$d'" EXIT KILL + cd "$d" + yt-dlp -x "$(xclip -o)" + exec st mpv --no-video * ;; esac