2018-07-09 03:26:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
clip="$(xsel -b -o)"
|
|
|
|
urls="$(echo $clip | grep -o 'https\?://[a-zA-Z0-9~#%&_+=,.?/-]\+')"
|
|
|
|
opts="qr
|
|
|
|
audio search"
|
|
|
|
if [ -n "$urls" ]; then
|
|
|
|
opts="$(printf '%s\ndownload\nplay' "$opts")"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#if [ -z "$urls" ]; then
|
|
|
|
#echo "Nope : $clip"
|
|
|
|
choice="$(printf "%s" "$opts" | dmenu -p "$(printf "%s" "$clip" | cut -c 1-48)")"
|
|
|
|
case "$choice" in
|
|
|
|
"qr")
|
|
|
|
printf "%s" "$clip" | qrencode -o - | feh -. -Z --geometry 400x400 -
|
|
|
|
;;
|
2019-02-15 23:41:54 +00:00
|
|
|
# Download supports optional folder target
|
|
|
|
"download"*)
|
|
|
|
path="$HOME/mus/$(printf "%s" "$choice" | cut -d " " -f 2-)"
|
|
|
|
[ -d "$path" ] || mkdir -p "$path"
|
|
|
|
cd "$path" || exit
|
2019-03-22 18:27:11 +00:00
|
|
|
youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$clip" 2>&1 | grep 'ERROR:' | xargs -n1 -d "\n" notify-send
|
|
|
|
#notify-send "Error while downloading: $clip"
|
2018-07-09 03:26:56 +00:00
|
|
|
;;
|
|
|
|
"play")
|
|
|
|
mpv --ytdl-format='bestvideo[height<=?1080]+bestaudio/best' "$clip"
|
|
|
|
;;
|
|
|
|
"audio search")
|
|
|
|
st -e mpv --ytdl-format=bestaudio ytdl://ytsearch:"$clip"
|
|
|
|
;;
|
|
|
|
*)
|
2019-02-15 23:41:54 +00:00
|
|
|
printf 'Nope\n'
|
2018-07-09 03:26:56 +00:00
|
|
|
;;
|
|
|
|
esac
|