1
0
Fork 0
mirror of https://github.com/Jonny007-MKD/OTR-DecodeAll synced 2025-01-22 08:49:50 +01:00

Check the XBMC state between the files

This commit is contained in:
root 2014-08-08 22:25:10 +02:00
parent 4c2b06f0d3
commit e4d62cdb9f

View file

@ -11,6 +11,7 @@ logMsgTypes=(" " "error" "warn" "info" "debug" "debugV")
logMsgColor=("\033[37m" "\033[31m" "\033[33m" "\033[37m" "\033[37m" "\033[37m") logMsgColor=("\033[37m" "\033[31m" "\033[33m" "\033[37m" "\033[37m" "\033[37m")
logLevel=0 logLevel=0
echoLevel=5 echoLevel=5
lastXbmcCheck=0
PwD=$(readlink -e $0) # Get the path to this script PwD=$(readlink -e $0) # Get the path to this script
PwD=$(dirname "$PwD") PwD=$(dirname "$PwD")
@ -58,18 +59,31 @@ function funcPerformChecks {
funcLog 1 "Please check the path to SaneRenamix (set to empty if not wanted)" funcLog 1 "Please check the path to SaneRenamix (set to empty if not wanted)"
exet=1 exet=1
fi fi
if [ -n "$xbmcUrl" ] && ! type "curl" >/dev/null 2>&1; then
funcLog 1 "Please install curl to check the XBMC state"
exet=1
fi
if [ $exet -eq 1 ]; then if [ $exet -eq 1 ]; then
funcUnlock funcUnlock
exit 1 exit 1
fi fi
funcPerformXbmcCheck
}
function funcPerformXbmcCheck {
local curTimestamp;
if [ $forceRun -eq 0 ] && [ -n "$xbmcUrl" ]; then # If we can and have to check whether XBMC is playing something if [ $forceRun -eq 0 ] && [ -n "$xbmcUrl" ]; then # If we can and have to check whether XBMC is playing something
curTimestamp=$(date +%s)
if [ $(($curTimestamp-$lastXbmcCheck)) -gt 10 ]; then # Only check all 10 seconds
playerID="$(curl -s $xbmcUrl/jsonrpc -H 'content-type: application/json;' --data-binary '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}' | grep -o "[0-9],.type.:.$1" | grep -o '[0-9]')" playerID="$(curl -s $xbmcUrl/jsonrpc -H 'content-type: application/json;' --data-binary '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}' | grep -o "[0-9],.type.:.$1" | grep -o '[0-9]')"
if [ -n "$playerID" ]; then if [ -n "$playerID" ]; then
funcLog 3 "XBMC is running, exiting now" funcLog 3 "XBMC is running, exiting now"
funcUnlock funcUnlock
exit exit
fi fi
lastXbmcCheck=$curTimestamp
fi
fi fi
} }
@ -237,6 +251,7 @@ function funcMakeVars {
function funcProcessFiles { function funcProcessFiles {
local files="`ls $inDir/*.otrkey 2> /dev/null `" # All otrkeys local files="`ls $inDir/*.otrkey 2> /dev/null `" # All otrkeys
for file in $files; do # For each otrkey for file in $files; do # For each otrkey
funcPerformXbmcCheck
filename="$(basename $file)" filename="$(basename $file)"
filename="${filename%.otrkey}" filename="${filename%.otrkey}"