[LINUX] Collection of my bash scripts for XBMC
Posted: February 26th, 2010, 10:22 am
I've been working on some linux scripts for integrating sabnzbd+ with my XBMC installation. I've used some topics here and some from the XBMC.org forum. Maybe someone can use these. It's all linux written in bash. It's verry basic because i'm still a noob in bash scripting. Been learning them for 3 days now. I'll post them per functionality. I have integrated some of them into one script.
Don't expect to have these script work out of the box for you! Make sure you have the script made executable. with chmod +x myscript.sh. A read that some people had to make the script "chmod 777 myscript.sh" to get it to work. To use the move script make sure you have write permissions with your sabnzbd+ user in the xbmc library folder. I hope these can help someone!
Send notification to XBMC when download is complete.
I use twilightnzb for downloading nzb's. So when i download a movie. Let's say Transformers (i name the nzb: Transformers (2007).nzb. The folder structure often looks like this: /complete/Transformers (2007).nzb/Transformers 2007 twilight.SRT/video_ts. So i want everything under Transformers 2007 twilight.SRT move one level up. The script checks if the is exactly one folder under the nzb folder. If that's true move that folder but use the nzb folder's name without the nzb, to you'r movie (library) folder. In this case with the name Transformers (2007).
Ok last one is a easy one. Update my Movies library.
I've called the last script on line 17 in the previous script when the movie could be moved. Just before the else statement. You can ofcourse also put the script in a function and call that.
Don't expect to have these script work out of the box for you! Make sure you have the script made executable. with chmod +x myscript.sh. A read that some people had to make the script "chmod 777 myscript.sh" to get it to work. To use the move script make sure you have write permissions with your sabnzbd+ user in the xbmc library folder. I hope these can help someone!
Send notification to XBMC when download is complete.
Code: Select all
#! /bin/bash
finaldir=$1
oriname=$2
cleanname=$3
status=$7
case $status in
0 )
status="OK";;
1 )
status="Failed Veri" ;;
2 )
status="Failed unpack";;
3 )
status="FverAndFunpack";;
esac
subject="$status : $cleanname"
message="In:$oriname"
wget -q --delete-after "http://XBMC:@192.168.1.251:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification($subject,$message,18000))" > /dev/null 2>&1
#for testing purposes
#echo "$1 : $3 : $4 : $5 : $6 : $7" >> ~/.sabnzbd/scripts/scripts.log
Code: Select all
#!/bin/bash
#Sabnzbd variabled assigned to my own variables
finaldir=$1
oriname=$2
cleanname=$3
status=$7
#This is the path where you wan't to move your movie to
myLibraryDir="/home/pietje/path/to/your/xbmc/movies/"
#This part copy's the directory in the nzb dir, to your own movies (library) folder
numberdirs=`find "$finaldir" -maxdepth 1 -type d | wc -l`
if [[ $numberdirs -eq 2 ]]; then
pathinnzb=`ls -d "$finaldir"*/`
mv "$pathinnzb" "$myLibraryDir$cleanname"
echo -e "\nmoved $pathinnzb to: movies\n $myLibraryDir$cleanname" >> ~/.sabnzbd/logs/sabnzbd.log
else
if [ $numberdirs -gt 2 ]; then
echo "Found more then 1 folder in $finaldir!" >> ~/.sabnzbd/logs/sabnzbd.log
fi
if [ $numberdirs -lt 2 ]; then
echo "Did not found any dirs in $finaldir!" >> ~/.sabnzbd/logs/sabnzbd.log
fi
fi
Code: Select all
#!/bin/bash
ipxbmc1="192.168.1.253"
portxbmc="8080"
user="XBMC"
pass=""
wget -q --delete-after "http://$user:$pass@$ipxbmc1:$portxbmc/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)" > /dev/null 2>&1
I've called the last script on line 17 in the previous script when the movie could be moved. Just before the else statement. You can ofcourse also put the script in a function and call that.