If no argument test clipboard content

This commit is contained in:
Jeremy Gardais 2021-01-06 17:34:32 +01:00
parent fa92f4fd06
commit 0807f93750
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 15 additions and 2 deletions

View File

@ -36,11 +36,24 @@ REQ_ARG_ERR='requires an argument'
WRONG_ARGS_ERR='wrong number of arguments passed to script' WRONG_ARGS_ERR='wrong number of arguments passed to script'
#===============================================================================
# try to get a youtube URL from clipboard
#===============================================================================
is_clipboard_youtube_url () {
infile=$(xclip -out -selection clipboard)
if printf "%s" "${infile}" | grep -q -E "http.*youtube.*"; then
printf "%b\n" "Clipboard content can be used: ${infile}"
else
usage "${WRONG_ARGS_ERR}"
fi
}
#=============================================================================== #===============================================================================
# check number of aruments passed to script # check number of aruments passed to script
#=============================================================================== #===============================================================================
[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}" [ $# -gt 0 ] || is_clipboard_youtube_url
#=============================================================================== #===============================================================================
@ -91,7 +104,7 @@ video_url=$(echo "${url}" | awk 'BEGIN{ RS ="" ; FS ="\n" }{print $1}')
audio_url=$(echo "${url}" | awk 'BEGIN{ RS ="" ; FS ="\n" }{print $2}') audio_url=$(echo "${url}" | awk 'BEGIN{ RS ="" ; FS ="\n" }{print $2}')
# kodi-send # kodi-send
#kodi-send --host="${ip}" --port=9777 --action="PlayMedia(udp://${ip}:1234?pkt_size=1316)" 1>/dev/null kodi-send --host="${ip}" --port=9777 --action="PlayMedia(udp://${ip}:1234?pkt_size=1316)" 1>/dev/null
# ffmpeg join audio and video and stream # ffmpeg join audio and video and stream
ffmpeg \ ffmpeg \