From dcb20d2641ebb933f68e25e35d78a85c509bb392 Mon Sep 17 00:00:00 2001 From: Jonny007-MKD Date: Wed, 6 Aug 2014 19:02:06 +0200 Subject: [PATCH] Introduced check whether XBMC is running. In this case we will simply exit --- config | 1 + otrDecodeAll | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config b/config index a81f3ee..8ba80b6 100644 --- a/config +++ b/config @@ -13,6 +13,7 @@ function funcConfigPre { # These values are set at the beginning of the script outDir="/Multimedia/Video/" # Final dir with videos torrentDb="/home/deluged/torrents.db" # File with file names and labels (see at github: OTR-TorrentDb) + xbmcUrl="user:password@localhost:8080" # Specify user, password and port for XBMC JSON API (HTTP interface) logFile="/home/deluged/otrDecodeAll.log" # path to the log file # log levels: 0=off; 1=error; 2=warn; 3=info; 4 debug; 5 verbose debug diff --git a/otrDecodeAll b/otrDecodeAll index a1fb358..265f7fc 100755 --- a/otrDecodeAll +++ b/otrDecodeAll @@ -61,6 +61,15 @@ function funcPerformChecks { if [ $exet -eq 1 ]; then exit 1 fi + + if [ $forceRun -eq 0 ] && [ -n "$xbmcUrl" ]; then # If we can and have to check whether XBMC is playing something + 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 + funcLog 3 "XBMC is running, exiting now" + funcUnlock + exit + fi + fi } @@ -113,7 +122,7 @@ function funcParam { function funcHelp { echo -e "\n\033[1;31m./otrDecodeAll.sh [-f -k -v -h] [-e user] [-p password] [-i inputDir] [-d decodedDir] [-c delugeDir] [-o outputDir]\033[0;37m" echo "-> FORCE" - echo -e " \033[36m-f\033[37m Make this script ignore the lockfile. This may result into decoding some files multiple times." + echo -e " \033[36m-f\033[37m Make this script ignore the lockfile and XBMC. This may result into decoding some files multiple times (perhaps corrupting them) and making XBMC less smooth." echo "-> REMOVE" echo -e " \033[36m-r\033[37m Make this script delete the original otrkey files." echo "-> KEEP"