From ae43b0bc907efefbbdb88fca13af7746da41a2ff Mon Sep 17 00:00:00 2001 From: lhark Date: Fri, 15 Feb 2019 18:41:54 -0500 Subject: [PATCH] [cliplumber] Add optional download folder, failure notif --- cliplumber | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cliplumber b/cliplumber index 99a9c2f..263bfab 100755 --- a/cliplumber +++ b/cliplumber @@ -15,9 +15,13 @@ case "$choice" in "qr") printf "%s" "$clip" | qrencode -o - | feh -. -Z --geometry 400x400 - ;; - "download") - cd ~/mus || exit - youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$clip" + # Download supports optional folder target + "download"*) + path="$HOME/mus/$(printf "%s" "$choice" | cut -d " " -f 2-)" + [ -d "$path" ] || mkdir -p "$path" + cd "$path" || exit + youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$clip" || + notify-send "Error while downloading: $clip" ;; "play") mpv --ytdl-format='bestvideo[height<=?1080]+bestaudio/best' "$clip" @@ -26,6 +30,6 @@ case "$choice" in st -e mpv --ytdl-format=bestaudio ytdl://ytsearch:"$clip" ;; *) - printf "Nope\n" + printf 'Nope\n' ;; esac