From 0807f93750fe69b80cf638f03f1007832d012730 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 6 Jan 2021 17:34:32 +0100 Subject: [PATCH] If no argument test clipboard content --- kodi.youtube | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kodi.youtube b/kodi.youtube index ec6568e..075ab93 100755 --- a/kodi.youtube +++ b/kodi.youtube @@ -36,11 +36,24 @@ REQ_ARG_ERR='requires an argument' 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 #=============================================================================== -[ $# -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}') # 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 \