Skip to content

Commit

Permalink
fixed an issue with not displaying a proper message
Browse files Browse the repository at this point in the history
  • Loading branch information
admin committed Dec 3, 2017
1 parent e97efce commit f7f8e1d
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions kodi-cli
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,6 @@
## using the command found at http://kodi.wiki/view/HOW-TO:Remotely_update_library
## .kodirc added by uriel1998

## Configure your KODI RPC details here

KODI_HOST=
KODI_PORT=
KODI_USER=
KODI_PASS=
LOCK=false

# If the script does not have configuration hardcoded, the script will
# search for it in $HOME/.kodirc

if [ -z "$KODI_HOST" ]; then
if [ -f "$HOME/.kodirc" ];then
readarray -t line < "$HOME/.kodirc"
KODI_HOST=${line[0]}
KODI_PORT=${line[1]}
KODI_USER=${line[2]}
KODI_PASS=${line[3]}
fi
fi

# Ensure some configuration is loaded, or exit.
if [ -z "$KODI_HOST" ]; then
show_help
exit
fi

function xbmc_req {
output=$(curl -s -i -X POST --header "Content-Type: application/json" -d "$1" http://$KODI_USER:$KODI_PASS@$KODI_HOST:$KODI_PORT/jsonrpc)
Expand Down Expand Up @@ -284,6 +258,42 @@ echo -e "\n kodi-cli -[p|i|h|s|y youtube URL/ID|t 'text to send']\n\n" \

}

## main
## check if we have any argument
if [ $# -eq 0 ];then
echo -e "\n failure: make sure there is at least one argument"
show_help
exit
fi

## ---- Configuration --- ##
## Configure your KODI RPC details here
KODI_HOST=
KODI_PORT=
KODI_USER=
KODI_PASS=
LOCK=false

# If the script does not have configuration hardcoded, the script will
# search for it in $HOME/.kodirc

if [ -z "$KODI_HOST" ]; then
if [ -f "$HOME/.kodirc" ];then
readarray -t line < "$HOME/.kodirc"
KODI_HOST=${line[0]}
KODI_PORT=${line[1]}
KODI_USER=${line[2]}
KODI_PASS=${line[3]}
fi
fi

# Ensure some configuration is loaded, or exit.
if [ -z "$KODI_HOST" ]; then
echo -e "\n failure: Some Kodi configurations are not loaded. Please make sure they are."
show_help
exit
fi

## Process command line arguments
while getopts "yqopstiudfhvmnjkl" opt; do
case $opt in
Expand Down Expand Up @@ -348,6 +358,4 @@ while getopts "yqopstiudfhvmnjkl" opt; do
done


if [ $# -eq 0 ];then
show_help
fi

0 comments on commit f7f8e1d

Please sign in to comment.