Allow to set IP Addr as argument
This commit is contained in:
parent
8f9ea40313
commit
dbad50664f
35
kodi.youtube
35
kodi.youtube
@ -16,17 +16,12 @@ usage () {
|
||||
[ -z "${1}" ] || echo "! ${1}"
|
||||
# display help
|
||||
echo "\
|
||||
$(basename "$0") -i url
|
||||
-i infile.(mp4|mov|mkv|m4v|aac|m4a|wav|mp3) or an http link"
|
||||
$(basename "$0") -u url
|
||||
-u http link or a video file.(mp4|mov|mkv|m4v|aac|m4a|wav|mp3)
|
||||
-i IP.AD.DR.ESS (default=127.0.0.1)"
|
||||
exit 2
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
# ip address localhost - change to your ip
|
||||
#===============================================================================
|
||||
|
||||
ip='127.0.0.1'
|
||||
|
||||
#===============================================================================
|
||||
# error messages
|
||||
#===============================================================================
|
||||
@ -41,9 +36,9 @@ WRONG_ARGS_ERR='wrong number of arguments passed to script'
|
||||
#===============================================================================
|
||||
|
||||
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}"
|
||||
url_arg=$(xclip -out -selection clipboard)
|
||||
if printf "%s" "${url_arg}" | grep -q -E "http.*youtube.*"; then
|
||||
printf "%b\n" "Clipboard content can be used: ${url_arg}"
|
||||
else
|
||||
usage "${WRONG_ARGS_ERR}"
|
||||
fi
|
||||
@ -60,10 +55,11 @@ is_clipboard_youtube_url () {
|
||||
# getopts check options passed to script
|
||||
#===============================================================================
|
||||
|
||||
while getopts ':i:h' opt
|
||||
while getopts ':u:i:h' opt
|
||||
do
|
||||
case ${opt} in
|
||||
i) infile="${OPTARG}";;
|
||||
u) url_arg="${OPTARG}";;
|
||||
i) ip="${OPTARG}";;
|
||||
h) usage;;
|
||||
\?) usage "${INVALID_OPT_ERR} ${OPTARG}" 1>&2;;
|
||||
:) usage "${INVALID_OPT_ERR} ${OPTARG} ${REQ_ARG_ERR}" 1>&2;;
|
||||
@ -71,13 +67,22 @@ do
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
#===============================================================================
|
||||
# ip address localhost - change to your ip
|
||||
#===============================================================================
|
||||
|
||||
## If ip wasn't defined
|
||||
if [ -z "${ip}" ]; then
|
||||
### Set it to localhost
|
||||
ip='127.0.0.1'
|
||||
fi
|
||||
|
||||
#===============================================================================
|
||||
# url
|
||||
#===============================================================================
|
||||
|
||||
# youtube-dl best format
|
||||
url=$(youtube-dl -f best -g --no-playlist "${infile}")
|
||||
url=$(youtube-dl -f best -g --no-playlist "${url_arg}")
|
||||
|
||||
# check url with ffprobe for errors and swap stderr and stdout to store error
|
||||
url_check=$(ffprobe -hide_banner -v warning -i "${url}" 3>&2 2>&1 1>&3 >/dev/null)
|
||||
@ -99,7 +104,7 @@ kodi-send --host="${ip}" --port=9777 --action="PlayMedia(${url},[noresume])" 1>/
|
||||
#===============================================================================
|
||||
|
||||
two_streams () {
|
||||
url=$(youtube-dl -g --no-playlist "${infile}")
|
||||
url=$(youtube-dl -g --no-playlist "${url_arg}")
|
||||
video_url=$(echo "${url}" | awk 'BEGIN{ RS ="" ; FS ="\n" }{print $1}')
|
||||
audio_url=$(echo "${url}" | awk 'BEGIN{ RS ="" ; FS ="\n" }{print $2}')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user